Using "cast(enum)" for explicit request of ctfe

Jakob Ovrum jakobovrum at gmail.com
Wed Dec 4 05:45:33 PST 2013


On Wednesday, 4 December 2013 at 13:16:35 UTC, monarch_dodra 
wrote:
> Problem is that doing this returns an immutable type, which 
> isn't quite the same as a ctfe variable (which was the initial 
> goal, as far as I'm concerned)

Immutable "global" variables with initializers are readable at 
compile-time (as the initializers are required to be readable at 
compile-time). I don't know what you mean by "CTFE variable".

It's probably better to use const over immutable though, so that 
it can accept values of a type with mutable indirection.

Using enum has issues, as elaborated upon by Don in this 
enhancement request[1] (for reference; I'm sure you remember 
them).

[1] http://d.puremagic.com/issues/show_bug.cgi?id=10950


More information about the Digitalmars-d mailing list