Re: Dealing with a Diamond of Death
Jeff Schwab wrote:
Why the heck do they have to forbid multiple inheritance in order to
avoid diamond inheritance? Why not forbid diamond inheritance only?
There are tons of situations where non-diamond multiple inheritance
would be extremely useful, but these languages go ahead and remove this
useful object-oriented tool.
I suspect that they avoid MI because of difficulty implementing it,
rather than difficulty using it.
Is it really so difficult to implement multiple inheritance in a
language and its compilers?
I do understand that diamond inheritance (what C++ implements as
virtual inheritance) can become complicated. However, what makes
multiple inheritance complicated?
And in this context when I say "complicated" I don't mean "it requires
n thousands of complex code to implement compiler support". That's just
technical detail. With "complicated" I mean eg. situations which are
ambiguous and there's no clear "best solution". An example of what I
consider "complicated" is exception throwing (and subsequent stack
unwinding) in C++: This is a very complicated issue, and there is no
clear "best solution" (afaik all solutions have their own little
problems, often related to efficiency and/or code size).