Inheritance of mixin

Andrew Benton via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 30 15:51:27 PDT 2016


On Saturday, 30 April 2016 at 22:14:47 UTC, Ed wrote:
> On Saturday, 30 April 2016 at 01:06:18 UTC, Andrew Benton wrote:
>> On Friday, 29 April 2016 at 19:11:24 UTC, tsbockman wrote:
>>> Rare as in, "effecting only a very small amount of real world 
>>> code" - not as in "effecting only a very small number of 
>>> people".
>>
>> [...]
>>
>> Additionally, any libraries that provide a base class with a 
>> mixin require inheritors to know about that mixin and provide 
>> it in their own code.
>>
>> [...]
>
> It looks like you miss the solution proposed above, using a 
> template this parameter. It's very clear and consise ! Actually 
> the mixin is even not necessary.

Unfortunately the solution with the templated "this" creates 
non-virtual functions.  Using the template and the classes in 
that solution, the following main method produces two UUIDs:

void main() {
     Base a = new Base(), b = new Inheritor();
     a.writeName.writeln;
     b.writeName.writeln;
}

which is very different from the output that we would want by 
having the specialization of Base.


More information about the Digitalmars-d mailing list