On Tuesday, 30 July 2013 at 10:45:26 UTC, Dicebot wrote:
On Tuesday, 30 July 2013 at 06:45:31 UTC, JS wrote:
void f()
{
pragma(msg, __FUNCTION__);
}
template t()
{
pragma(msg, __FUNCTION__);
}
void main(string[] argv)
{
readln();
}
the function displays main.f. The template displays nothing.
I'd prefer it to display main.t! or something unique so I can
use it as a hash.
1) Pragma's are printed upon instantiation. You need to use
something like alias _ = t!(); to force it.
2) You may workaround it by wrapping pragma in stub function.
Though I do agree that something like __ENCLOSING__ may be
useful (assuming it also covers aggregates)
1. No, the code actually will print the message but the error
shows up right after(well, depends on which error, the one I get
inside templates works fine except the without the
assignment/alias, no further compilation is done due to the
error(but the message is printed).
And what is a stub function?