template mixins vs. string mixins

Jacob Carlborg doob at me.com
Sat Nov 6 06:51:01 PDT 2010


On 2010-11-06 11:13, Don wrote:
> Trass3r wrote:
>> In the past template mixins were a neat special usecase of templates.
>> Now with the "mixin template()" syntax they've become a separate thing
>> because you can add special code for handling them, e.g. allowing them
>> to add constructors to classes.
>>
>> The question is: what is their right to exist? Is there anything you
>> can do with them you can't with string mixins (or vice versa)?
>
> I've personally never seen a use for template mixins.

They can be used as a form of attributes/annotations. They can also be 
used for simulating multiple inheritance. Extract the content of a class 
into a template and write an interface for the class.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list