Non compile time evaluation for initializers
Steven Schveighoffer
schveiguy at yahoo.com
Thu Oct 25 13:29:54 PDT 2007
Is there a good reason why the compiler does not allow non-CTFE initializers
for non-const variables?
For instance, this does not work:
Logger log = Log.getLogger("test");
but this does:
Logger log;
static this()
{
log = Log.getLogger("test");
}
But why is it necessary to prevent the first from compiling to the
equivalent of the second? As far as I'm concerned, it's OK if it doesn't
evaluate at compile time. And it's much more convenient to write the first
version when you are setting up global or static variables instead of using
the static this() form. In my mind, CTFE is a form of optimization, one
which I can live without if it's not possible, but I still want to be able
to compile :)
-Steve
More information about the Digitalmars-d
mailing list