Multiple Inhertiance?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 6 13:56:38 PST 2014


On Thursday, 6 November 2014 at 15:25:11 UTC, Patrick Jeeves
wrote:
> On Thursday, 6 November 2014 at 08:04:33 UTC, Ola Fosheim 
> Grøstad
> wrote:
>> On Thursday, 6 November 2014 at 00:50:23 UTC, bearophile wrote:
>>> I think not giving language support means that D designers 
>>> don't want it to be easy to do. And this is good.
>>
>> Then why are they adding multiple alias this, which appears to 
>> be worse?
>
> I don't really see how multiple alias this is better or worse
> than multiple inheritance.  They descirbe completely different
> relationships, Multiple Aliasing describes an is-both
> relationship, while Multiple Inheritance describes an
> is-from-a-certian-point-of-view-a relationship.  Atttempting to
> use compositing to emulate will only result in feature envy, 
> data
> duplication, the space of the bookkeeping needed to share the
> data exceeding the space of the data being shared, cache misses,
> etc.
>

Multiple inheritance have various issue, like the well known
diamond shaped inheritance problem. There are also many
implementation issues when it come to object layout and base
class retrial, which are all trivial with a single inheritance
model.

Considering it come with problems, both in term of language
design and efficient implementation, it has to pull its weight.
And I'm yet to see a good use case for it.

In the other hand, alias this (or prototypal inheritance model in
general) do not suffer from these issues. It also have some good
use case like entity framework.


More information about the Digitalmars-d mailing list