3 ms·
I'll quote you as my response: "That would move the performance impact to runtime (and it would be everywhere)" and "You have to track dependencies between func
by SolarNet 10y ago
I'll quote you as my response: "That would move the performance impact to runtime (and it would be everywhere)" and "You have to track dependencies between functions, which costs memory, and recompile functions when methods they depend on are changed, which costs compile time" and then quote myself "this will take up even more memory". Also I'd be curious to hear your thoughts on multi-threading.
Also real systems have many libraries. Which will each take turns in defining things. And some may run initialization code, causing certain things in their library to run. The fact of the matter is you don't have "real" multi-methods because of it, and it's a problem with making large systems.
- StefanKarpinski 10y agoI'm not saying that interleaving of execution and definition doesn't happen – it definitely does, that's how library loading works in dynamic languages. However, it is demonstrably not common to define methods for a type, call them, and then define methods that overwrite those methods.
- SolarNet 10y agoBut in a language with multi methods defining new extensions to the type hierarchy is defining methods that overwrite some other methods. If startup code for a library calls any methods which are later meant to be extended you are going to get weird unexpected behavior. Lets see, there is a logging library with a custom string formatter, in another library I specialize the string formatter, and I log that the library started up with a value based on that abstract tag. Now as a user I specialize a concrete type for logging, but it doesn't work, why? That's a weird error, and also, the expression problem via multi-methods, well done you guys implemented multi-methods that don't solve one of the core purposes of multi-methods. How much you wanna bet I can find startup code in many python libraries which calls code that is later specialized by users. Edge cases are where it's important.