Inheritance of mixin

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 29 03:59:20 PDT 2016


On 29.04.2016 07:35, tsbockman wrote:
>
>> What are the reasons that mixin shouldn't be able to be used to change
>> the behavior of a whole hierarchy?
>
> Mixins are a fairly simple and elegant feature both to use, and to
> implement in the compiler. Your proposal kills that simplicity,

It is not complicated, we'd just need a way to specify that a mixin 
should be inserted into all subclasses.

> in the name of saving one line of code per class for a rare use case.

The use case isn't rare (it is a quite popular request, at least four 
independent instances that I remember).

Having a mixin in all classes in some subtree of the class hierarchy can 
be a good idea. Of course one can easily do it manually, but it is 
always nice to get rid of boilerplate.


More information about the Digitalmars-d mailing list