enum abuse
Vladimir Panteleev
vladimir at thecybershadow.net
Fri Feb 28 22:41:06 PST 2014
On Saturday, 1 March 2014 at 05:39:24 UTC, Meta wrote:
> Hmm, I didn't know that. Interesting. I think this was a mistake
> on Andrei's part, though. The concept of enumerations doesn't
> have anything to do with evaluating an expression at compile
> time
It doesn't.
enum x = expression;
is the same as
enum
{
x = expression
}
and minding this trivial rewrite, it generally acts in exactly
the same way as C++ and other languages (plus D's CTFE
capabilities, naturally).
That the compiler has to fully evaluate the expression, CTFE
included, to calculate the value of x, is an obvious consequence
of enum semantics.
More information about the Digitalmars-d-learn
mailing list