4 ms·
Interesting article! I have one nit-pick: Multiple dispatch doesn't, in and of its self, imply something isn't object oriented. You can certainly argue that mu
by scottdw2 15y ago
Interesting article!
I have one nit-pick: Multiple dispatch doesn't, in and of its self, imply something isn't object oriented. You can certainly argue that multiple dispatch, as it exists in CLOS is not object oriented, but it is possible to have "object-oriented" multiple dispatch.
VB.NET is a good example.
The "late bound" dispatcher in VB.NET will:
1) Dynamically construct a "method-group" using the runtime type of a receiver of a method call. This collects all appropriately named instance methods in the receiver type and any of it's base types.
2) Dynamically perform overload resolution using the runtime type of each method argument. This behaves like the static overload resolution done in the compiler except that it
uses dynamic types, rather than static types, and happens at runtime. It also doesn't consider extension methods.
In any case, this yields method dispatch that varies dynamically based on the runtime type of multiple arguments. It is very similar to multi-methods in CLOS, except that preference is given to the receiver over other parameter types, and that you can't override a "multi-method" without modifying the definition of at least one type.