3 ms·
There's pretty big differences in usage between multimethods in Clojure and Julia. I've used both a decent amount. All functions in Julia are multimethods by de
by lenticular 8y ago
There's pretty big differences in usage between multimethods in Clojure and Julia. I've used both a decent amount. All functions in Julia are multimethods by default. If you don't use type annotations, a new method will be generated whenever you call the function with new argument types. This explicit type specialization is a very important part of why Julia can have such a consistently fast JIT despite its dynamicity.
Errors from missing or conflicting methods tend to not happen much in practice.
https://docs.julialang.org/en/v0.7.0/manual/methods/ https://docs.julialang.org/en/v0.7.0/manual/methods/
- nicoburns 8y ago> If you don't use type annotations, a new method will be generated whenever you call the function with new argument types. Damn. That's a pretty clever trade off between dynamic and static types.
- vanderZwan 8y agoI vaguely recall a talk by Stefan Karpinsky where he mentions meeting one of the big names in compiler land (working on V8 or something) and they said Julia's JIT is just a lazily evaluated AOT compiler, and as a result much simpler than the JITs typically seen in other languages.
- tombert 8y agoForgive a bit of ignorance here, but that doesn't sound terribly different than overloading functions in C++. Am I way off on that?
- KenoFischer 8y agoThe difference is run-time (semantically) vs compile time. If you had overloading at runtime in C++, you wouldn't need virtual functions or any of the thousands of OO "patterns" (visitor, factory, etc.), that are working around the lack of this capability.