Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminology: overloading versus multiple dispatch #1

Open
rauschma opened this issue Jul 31, 2013 · 3 comments
Open

Terminology: overloading versus multiple dispatch #1

rauschma opened this issue Jul 31, 2013 · 3 comments

Comments

@rauschma
Copy link

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) { ... });
...

[1] http://en.wikipedia.org/wiki/Multiple_dispatch

@mariusGundersen
Copy link
Owner

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.

Thanks for the feedback

[1] https://github.com/mariusGundersen/Overload/blob/master/source/overload.js#L90

@mikermcneil
Copy link

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 :)

@Nate-Wilkins
Copy link

The unicorns @mikermcneil... you forgot the unicorns...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants