V Tue, 02 Dec 2014 04:05:16 +0000 bitwise via Digitalmars-d <[email protected]> napsáno:
> On Monday, 1 December 2014 at 07:28:28 UTC, Daniel Kozák via > Digitalmars-d wrote: > > V Mon, 01 Dec 2014 00:07:10 +0000 > > bitwise via Digitalmars-d <[email protected]> napsáno: > > > >> > But I just try to say you can omit mixin word in template > >> > declaration. Because it doesn't have any effect. > >> > >> mixin != mixin template != template > > Yes and no :) > > > > import std.stdio; > > > > mixin template t1() { > > int x = 5; > > } > > > > void main(string[] args) > > { > > mixin t1; > > writeln(x); > > } > > > > is same as: > > > > import std.stdio; > > > > template t1() { > > int x = 5; > > } > > > > void main(string[] args) > > { > > mixin t1; > > writeln(x); > > } > > Heh... Guess you got me there ;) > > That is strange though... I don't see in the docs that mixin > templates have been deprecated, and can't seem to find anything > that doesn't work in both templates and mixin templates. The > "mixin name" usage is also not present in the docs for regular > templates. There is one limitation of mixin template. You can not do this (instantied mixin template): import std.stdio; mixin template t1() { int x = 5; } void main(string[] args) { alias t1!() T; writeln(T.x); } But this is valid: import std.stdio; template t1() { int x = 5; } void main(string[] args) { alias t1!() T; writeln(T.x); }
