That is hardly the only place that has a constant-expression in the grammar. (BTW, D enums can also be floats, and even string literals!) You could use CTFE to initialize const floating point globals. static_assert also takes a constant-expression.
> There's just a boatload of gotchas.
The D community has 17 years experience with it. It remains an indispensable feature.
As for embedding a printf, that has come up. Recall elsewhere I said that only the path through a function has to be pure for CTFE to work, not the whole function?
int sum(int a, int b) {
int s = a + b;
if (!__ctfe) printf("sum is %d\n", s);
return s;
}
__ctfe is a keyword that says "CTFE is executing this function".> If you could use this feature to define huge matrices of floats, that'd be pretty cool!
I use it to statically initialize complicated tables at compile time. Before CTFE, I wrote a separate executable that would emit source code with the array initializer. I like the new way mucho bettero.
If you prefer "hideous hacks" (your words!) I won't take that away from you.