struct inheritance

kris foo at bar.com
Thu Aug 30 17:47:39 PDT 2007


Bill Baxter wrote:
> Let us all turn our copies of WalterAndrei.pdf to page 40 where yea 
> verily it doth say:
> 
>     struct M { int a; }
>     struct S {
>        M m;
>        alias m this;
>        int b;
>     }
> 
> Why not just allow mixin to do this?
> 
>     struct M { int a; }
>     struct S {
>        mixin M;
>        int b;
>     }
> 
> That's basically the way it's done now except now it would be more like:
> template MMixin() { int a; }
> struct M { mixin M; }
> struct S { mixin M; int b; }
> 
> Just let us treat a struct like a zero arg template for mixin purposes.
> 
> --bb


Perhaps because the alias itself is optional? It just brings the members 
of 'm' into the namespace of 'S', without requiring an explicit S.m.a 
dereference.

On the other hand, mixin is the work of the devil :p



More information about the Digitalmars-d mailing list