nested class inheritance

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Fri Jul 13 12:36:54 PDT 2012


On Fri, Jul 13, 2012 at 11:30 PM, Andrei Alexandrescu <
SeeWebsiteForEmail at erdani.org> wrote:

> On 7/13/12 3:18 PM, Christophe Travert wrote:
>
>> Andrei Alexandrescu , dans le message (digitalmars.D:172280), a écrit :
>>
>>> For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
>>>> because the Apple, which AppleSeed sees is the same object, which
>>>> Fruit.Seed sees as it's base type Fruit.
>>>>
>>>
>>> That would mean AppleSeed has two outer fields: a Fruit and an Apple.
>>>
>>
>> Only one. Apple. And when AppleSeed.super seed this Apple, it sees a
>> fruit.
>>
>> AppleSeed a;
>> assert(is(typeof(a.outer) == Apple));
>> assert(is(typeof(a.super) == Seed));
>> assert(is(typeof(a.super.**outer) == Fruit));
>> //but:
>> assert(a.outer is a.super.outer);
>>
>> If you can't figure out how can a.outer and a.super.outer have two
>> different types, but be the same, think about covariant return.
>>
>
> Makes sense, thanks.
>
> Andrei
>
>
The initial question was: why does DMD 2.059 reject this if this makes
sense?
It's not even a new feature. It's a (possibly) new (and apparently
sensible) use case of an existing feature.

I came up with this when I was trying to work around the limitation of not
having multiple inheritance.

-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120713/fe901271/attachment.html>


More information about the Digitalmars-d mailing list