Why can't we derive struct's? (Hansel & Gretel)

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Dec 28 00:36:15 UTC 2018


On Fri, Dec 28, 2018 at 12:25:14AM +0000, luckoverthere via Digitalmars-d wrote:
> On Thursday, 27 December 2018 at 20:15:04 UTC, Jonathan M Davis wrote:
> > As it is, I think that having even a single alias this should be
> > done with caution and relatively rarely. And if we had the ability
> > to have multiple alias this-es on a type, I would think that it
> > should be used extremely rarely. But the very fact that it existed
> > could have some nasty repercussions (especially for generic code). I
> > don't know that that means that we shouldn't have the feature, but
> > it definitley concerns me.
[...]
> Arguably, in a sense, we already have multiple alias this's. It just
> has to be done through 1 alias this per struct.
> 
> 
> struct A {
>   int a;
> };
> 
> struct B {
>     A a_;
>     int b;
>     alias a_ this;
> }
> 
> struct C {
>     B b_;
>     int c;
>     alias b_ this;
> }
[...]

That's not multiple alias this, that's just a chain of alias this's. A
linear class inheritance hierarchy is not equivalent to multiple
inheritance.


T

-- 
The right half of the brain controls the left half of the body. This means that only left-handed people are in their right mind. -- Manoj Srivastava


More information about the Digitalmars-d mailing list