On Tuesday, 26 March 2013 at 23:00:40 UTC, Timon Gehr wrote:
On 03/26/2013 10:28 PM, Joseph Cassman wrote:[...]Bad code. Use enum for compile-time constants. This will work: struct A{ void b(){ size_t y; mixin(c!("y")); } template c(string x){ enum c = "while(" ~ x ~ " < 100){" ~ x ~ "++;}"; } }
I agree. No need for the memory allocation in this case.Perhaps the example on the tutorial page could be updated accordingly.
http://dlang.org/mixin.html Appreciate the help Joseph
