Reddit: why aren't people using D?

Rainer Deyke rainerd at eldwood.com
Fri Jul 24 19:29:06 PDT 2009


Andrei Alexandrescu wrote:
> Rainer Deyke wrote:
>> Composition instead of inheritance?  Doesn't work if I need virtual
>> functions.
> 
> This is going in circles. You started from "implementation inheritance
> of value types, even without actual polymorphism".

Yes, but implementation inheritance may involve customization points.
Virtual functions are one of of providing this customization.  The
curiously recurring template pattern provides another way.  Either way,
the class looks like a non-polymorphic value type from the outside.

Simple composition does *not* work here, unless the inner component has
a pointer to the outer aggregate.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list