On 2013-06-11, 22:15, Seany wrote:

On Tuesday, 11 June 2013 at 20:00:23 UTC, Simen Kjaeraas wrote:
On 2013-06-11, 21:52, Seany wrote:

Hello

i read here that enums, once initialized, are constants :
http://ddili.org/ders/d.en/enum.html

However, i need a method, if possible, to dynamically (cexecution time) definition of enums, and updating them.

anyidea how that can be done? using const and/or inout, and passing an array / tuple to a function?

So you're saying you need something like this?

struct MyEnum {
    int value;
    static MyEnum a(0);
    static MyEnum b(1);
}

void foo( ) {
   MyEnum.b = MyEnum(4);
}


thank you, but that means that when i need this to behave as const, i should use proper keywords ya?

I'm not sure I follow. (I must admit I find this whole discussion a bit
weird, as we're basically just making glorified global variables)

When do you want it to behave as const? When being used as a local
variable?

void foo() {
    const MyEnum var = MyEnum.a;
}

Or are you asking for MyEnum.a to be const except under certain
circumstances? If so, how, why, when and are you sure that makes sense?

--
Simen

Reply via email to