Why no multiple-dispatch?
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 25 10:28:44 PDT 2014
On Monday, 25 August 2014 at 17:16:10 UTC, Idan Arye wrote:
> * Alternative implementations need to implement them(even
> though the frontend is shared, there can always be some
> complications(plus I think mutli-methods might need some
> backend modifications as well, thhoguh I'm no expert on that
> matter))
>
> * Risking regressions - changing the code will never be as
> orthogonal as changing the data it works on...
>
> The point is that the usefulness of multi-methods, and the
> inconvenience of having as a library solution are not nearly
> big enough to pay that price.
If we assume just double-dispatch over class-types and that you
instantiate all functions first. Couldn't you then have this:
eat(virtual BaseBeing v, virtual BaseFood f,float amount){}
eat(virtual Human v, virtual Fruit f,float amount){]
eat(virtual Human v, virtual Stone f,float amount){}
eat(virtual Monster v, virtual Corpse f,float amount){}
eat(virtual Human v, virtual Corpse f,float amount){}
Then extend the typeinfo of classes in the first param with a
minimal typeid and 2D table that lists all combinations that the
"custom linker" can find based on the mangling?
Or maybe there are some hidden traps…
More information about the Digitalmars-d-learn
mailing list