Why no multiple-dispatch?

Idan Arye via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 24 18:34:13 PDT 2014


On Monday, 25 August 2014 at 01:10:32 UTC, Aerolite wrote:
> -- No syntax modification (unless you want the feature to be
> optional)

If this ever gets into the core language, it absolutely must be 
optional! Think of the implications of having this as the default 
and only behavior:

  * Every overloaded function will have to do a runtime typecheck 
- this not only causes a usually unnecessary overhead but also 
has a negative impact on branch prediction.

  * No way to reuse the overload that accepts an object of the 
parent class inside the implementation of the overload that 
accepts an object of the child class.

  * What if you have multiple overloads that happen to be 
templated? Now the compiler will have to instantiate them all!



Anyways, I don't think you get just how strong this language's 
tendency to push features to the library is, so I'd like to point 
you to this post by the language's creator:

http://forum.dlang.org/thread/lt00a9$2uoe$1@digitalmars.com#post-lt00a9:242uoe:241:40digitalmars.com


More information about the Digitalmars-d-learn mailing list