You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Overloading dispatches statically, via static type information (Java). A better term for what you are doing is “multiple dispatch [1]” (Common Lisp, Clojure). You could structure your API like this (possibly with different names):
var createPerson = createMultiMethod();
createPerson.addMethod([String], function (name) { ... });
createPerson.addMethod([String, Number], function (name, age) { ... });
...
Internally the name multiMethod is already used [1], but I wanted to give the entry point a name which described what it did, not how it did it. Maybe overloading isn't a good name for a dynamic language, but I think more people are familiar with the concept of overloading than have heard of multiple dispatch (I hadn't, but the wikipedia article you provided is a good read).
I like the python example, which is almost exactly the same syntax as I have, although I'm not familiar with Python. It's good to see that this is a common way of solving the problem.
Actually I like overloading because it helped me know immediately what you were talking about. Fortunately, we get to ignore lots of baggage from the java community over here in lollipop, pixie stick, JavaScript land :)
Overloading dispatches statically, via static type information (Java). A better term for what you are doing is “multiple dispatch [1]” (Common Lisp, Clojure). You could structure your API like this (possibly with different names):
[1] http://en.wikipedia.org/wiki/Multiple_dispatch
The text was updated successfully, but these errors were encountered: