Why no multiple-dispatch?
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 25 01:45:14 PDT 2014
On Monday, 25 August 2014 at 07:36:22 UTC, Idan Arye wrote:
> Are you suggesting the compiler will try to resolve the
> polymorphism at compile-time, looking at all possible paths
> that lead to a function call to check all possible runtime
> values it's object arguments can get?
I've argued for whole program analysis before and this is another
example where it would be useful :-). When you have figured out
the worst-case use pattern you can either make one function
virtual and then inline the others as a switch or you can create
class-ids that can be hashed perfectly to an array of function
pointers.
However, why do you want multiple dispatch? I cannot think of any
application level use scenario where you have two class
hierarchies that you have no control over. So I don't really see
the value of multiple dispatch in a system level programming
language. Perhaps if you want to use D for an application level
DSL? What are the use scenarios you guys have experience with
where multiple dispatch was indispensable?
Ola.
More information about the Digitalmars-d-learn
mailing list