struct inheritance
Robert Fraser
fraserofthenight at gmail.com
Thu Aug 30 17:42:05 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
It amounts to the same thing, so it just depends on which syntax you prefer. Personally, I like...
struct S : M { int b; }
... meaning S is non-polymorphically inherited from M. I guess the argument against taht syntax was that it would be confusing for people from a C++ background who assume polymorphic inheritance for structs.
Anyways, it's up to Walter to decide on the syntax, and he says "alias this".
More information about the Digitalmars-d
mailing list