Multiple Inhertiance?
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 6 08:25:02 PST 2014
On Thursday, 6 November 2014 at 15:25:11 UTC, Patrick Jeeves
wrote:
> I don't really see how multiple alias this is better or worse
> than multiple inheritance.
It is worse because:
1. When you design a class hierarchy with multiple inheritance
you don't reuse something made for another purpose, you design it
as a whole for a particular purpose and you can use virtual base
class and virtual function to resolve problems.
2. "multiple alias this" messes with the type system in bad ways.
Classical multiple inheritance does not (due to the resolution
mechanisms).
But there is no good reason to include either because you should
model not from the object, but from how you care going to use the
object. Therefore you can usually decide one view as more
important for a particular application.
> IMHO MI is too useful a feature to be left out of any language,
> even if most languages butcher it to the point that it's used as
> an is-both relationship.
If you want good MI then you need to build the language around it
from the start, but you can always do without.
Yes, that means you have to select one perspective and break down
the model in a different way, but it isn't that hard to do. And
you can resolve conflicts by adding virtual functions in the base
class if you want that kind of model.
For a game it would be better to break up the representation for
the game object into more than a single aggregate. Using MI and a
single object is going to hurt performance.
More information about the Digitalmars-d
mailing list