struct inheritance

Bill Baxter dnewsgroup at billbaxter.com
Fri Aug 31 00:17:36 PDT 2007


Don Clugston wrote:
> Reiner Pope wrote:
>> 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
>>
>> Template mixins require that the sourcecode of the template is 
>> available to the compiler. Aliases don't. In this sense at least, 
>> aliases are cleaner.
 >>  -- Reiner

Just to be clear -- I'm not saying the 'mixin M' should be a shortcut 
for the similar-looking template mixin.  Just suggesting to reuse the 
keyword for a similar concept.  You want to add in the members of 
another struct and at the same time avoid it looking like polymorphic 
inheritance.


> Also, Walter wants to get [rid] of template mixins. (That was discussed a 
> little on the Saturday).

Now that's interesting.  Replaced by macros?


--bb



More information about the Digitalmars-d mailing list