Multiple subtyping with alias this and nested classes

Max Samukha spambox at d-coding.com
Sat Oct 3 11:19:05 PDT 2009


On Sat, 3 Oct 2009 14:11:37 -0300, Leandro Lucarella
<llucax at gmail.com> wrote:

>
>Ok, then, I just find it ugly and unnecessary since you can do the same
>with interfaces+mixins.

Actually, you can't. Consider:

interface IBlipper
{
   void blip();
   void nameCollision();
}
template Blipper()
{
   void blip() {}
   void nameCollision() {}
}

interface IFlipper
{
   void flip();
    void nameCollision();
}
template Flipper()
{
   void flip() {}
   void nameCollision() {}
}

class FlippingBlipper : IBlipper, IFilpper
{
   mixin Flipper;
   mixin Blipper;
}

The above sucks because we can't specify which nameCollision gets
implemented by which mixin. In current D, nameCollision of both
interfaces is implemented by Flipper.

We would probably be able to overcome the limitation if and when
explicit interface instantiation is implemented:

template Blipper()
{
   void IBlipper.blip() {}
   void IBlipper.nameCollision() {}
}

template Flipper()
{
   void IFlipper.flip() {}
   void IFlipper.nameCollision() {}
}

Until then, mixin + interface just doesn't work.

>It's just a matter of personal preferences (as
>I said in my first mail), there is no point on arguing about it. =)



More information about the Digitalmars-d mailing list