Why no multiple-dispatch?
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 24 17:08:24 PDT 2014
On Sunday, 24 August 2014 at 23:42:51 UTC, Aerolite wrote:
> Hey all,
>
> I was surprised to learn yesterday that D does not actually
> support Multiple-Dispatch, also known as Multimethods. Why is
> this? Support for this feature is already present in Scala, C#
> 4.0, Groovy, Clojure, etc... Would it not make sense for D to
> remain competitive in this regard?
>
> While I think many of us are aware that problems of the nature
> that require Multiple-Dispatch can be approached with the
> Visitor
> Pattern, there seems to be a general consensus that the Visitor
> Pattern is pretty cumbersome and boilerplate-heavy, and thus
> should be avoided.
>
> The common response from my searching around seems to be that a
> template-based, static implementation of Multiple-Dispatch is
> the
> go-to solution in D, but considering the existing template-bloat
> issues we have, I can't help but wonder if language support for
> this feature might be a better path to go down. Seems like it
> wouldn't be too difficult to implement, although I've not looked
> very deeply into dmd's source-code.
>
> So what seems to be the situation here?
At this point, if something can be implemented in a library
rather than in the language, the odds are low that it will be
solved in the language. The language is very powerful and already
a bit complicated, so usually the response for questions like
this is that we'll take advantage of D's existing features to
implement the new feature rather than complicating the language
further. If you could come up with a very good reason why it had
to be in the language, then maybe it would happen, but my guess
is that that's not likely to happen.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list