Eponymous templates ambiguity

andrea9940 no at mail.plz
Sat Aug 3 04:27:28 PDT 2013


Hello D world, I have just started using templates and mixins to 
generate some boilerplate code and I have found a little 
ambiguity:

This code compiles fine:

private template genTypes()
{
	string eval() { ... }
	const(char[]) genTypes = eval();
}
mixin(genTypes!());  // Working

But this does not, why ?

private template genTypes()
{
	string eval() { ... }
	string genTypes = eval();
}
mixin(genTypes!()); // Error: variable genTypes cannot be read at 
compile time

I would expect both version to work.

( complete code at http://pastebin.com/FhmrgmZZ )


More information about the Digitalmars-d-learn mailing list