mixin template

Dan Killebrew dank at gmail.com
Thu Jan 30 22:24:25 PST 2014


> mixin template Foo(alias a){ alias Foo=a; }
> pragma(msg, Foo!2); // error
>
> template Bar(alias a){ alias Bar=a; }
> pragma(msg, Bar!2); // ok

Perhaps I was unclear. What I meant:
What does 'mixin template' do that 'template' does not?
Where would I use 'mixin template'?

As far as I can tell, 'mixin template' does nothing new; 
'template' is sufficient. Thus, 'mixin template' seems like 
pointless extra syntax.

As I said before, this page http://dlang.org/template-mixin.html 
could have replaced all instances of 'mixin template' with 
'template' and it would compile (I tested all examples) and run 
the same (perhaps not true? I tested about half).

Even the example in TDPL on page 284 works the same when I 
replace 'mixin template' with 'template': (this is my slightly 
modified version) http://dpaste.dzfl.pl/b582c899fc3f


More information about the Digitalmars-d-learn mailing list