Multiple subtyping with alias this and nested classes

Max Samukha spambox at d-coding.com
Sun Oct 4 02:04:07 PDT 2009


On Sun, 04 Oct 2009 00:10:30 +0200, Yigal Chripun <yigal100 at gmail.com>
wrote:

>
>class FlippingBlipper : IBlipper, IFilpper
>{
>     mixin Flipper F;
>     mixin Blipper B;
>     alias F.nameCollision nameCollision;
>}
>

The problem is that IBlipper.nameCollision is totally unrelated 
to IFlipper.nameCollision (for example, if the interfaces/mixins come
from third-party libraries, whose developers don't know or care
about each other, e.g. Tango/Phobos :P). That's why either
nameCollision must have its own implementation.

In current D:

auto fb = new FlippingBlipper;
IFlipper f = fb;
IBlipper b = fb;
f.nameCollision;
b.nameCollision;

Both calls are dispatched to the same implementation (the one provided
by Flipper template), which is incorrect and undesirable.

>I wonder if the following would work:
>
>class FlippingBlipper : IBlipper, IFilpper
>{
>     mixin Flipper IFilpper;
>     mixin Blipper IBlipper;
>}
>
>

I don't think so.



More information about the Digitalmars-d mailing list