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 )

Reply via email to