Suggestion: Walter Bright, why not to implement multiple inheritance in D?
Larry Evans
cppljevans at cos-internet.com
Mon Dec 4 05:18:24 PST 2006
On 12/02/2006 10:11 PM, Burton Radons wrote:
> Larry Evans wrote:
>
>> On 12/02/2006 09:27 AM, Burton Radons wrote:
[snip]
> And allow the diamond because Winged can't override anything from
> Animal. This is bad because Animal might have stuff Winged has an
> opinion on, but more discrete selections of inheritance (which are a
> good idea anyway) allows us to defeat the diamond when we need to:
>
> Reproduction
> Movement
> Animal : Reproduction, Movement
> Mammal : abstract Animal, Reproduction
> Winged : abstract Animal, Movement
> Bat : Mammal, Winged
>
> In this case Mammal and Winged are exclusive, so the tree works properly.
>
> I'd analyse your example more but I'm unfamiliar with Boost. Can you
> factor the problem so that it can be expressed in terms of animals? :-)
Well, I'm kinda agreeing with Walter. AFAICT, the example in
boost which used inherit was used to create a tuple, and since
there's now a better way (as Walter pointed-out), I'm reluctant
to try. However, if I did, there would be a problem with the
abstract Animal (or virtual Animal in c++ case). I don't
see a way that can be done with c++ metaprogramming since
all the args to boost::mpl::inherit have to be types, and, AFAICT,
there's no type, virtual X, for any type X, in c++.
More information about the Digitalmars-d
mailing list