3 ms·
Dispatch is the process of selecting and executing the matching overload. Multiple-dispatch refers to the ability to select the best overload based on more than
by brandonbloom 12y ago
Dispatch is the process of selecting and executing the matching overload. Multiple-dispatch refers to the ability to select the best overload based on more than just the first argument. C++ can do arity and type-based multiple-dispatch, but only statically. Julia supports dynamic multiple dispatch, where as C++'s virtual methods are only single-dispatch dynamically.
- StefanKarpinski 12y agoPrecisely. This may sound pedantic or academic, but in practice when static overloading and dynamic dispatch differ, the static behavior is usually not what you want. In my experience, this makes it painful to make code that is polymorphic in multiple arguments behave correctly in C++ (double dispatch [1] is one of the necessary but awkward tactics that's used), whereas multiple dispatch just works. And of course, almost working and actually working are a world apart even though they sound so close. [1] http://lostechies.com/derekgreer/2010/04/19/double-dispatch-is-a-code-smell/ http://lostechies.com/derekgreer/2010/04/19/double-dispatch-...