TDPL enum greet = "Hello";

Simen kjaeraas simen.kjaras at gmail.com
Sun Aug 8 08:19:01 PDT 2010


Paolo Invernizzi <arathorn at fastwebnet.it> wrote:

> Hi all,
> On page 273 of TDPL, we have:
>
> enum euler = 2.78;
> euler = 2.73 // Error! Cannot modify enum value!
>
> But with D 2.047 I can do:
>
> enum greet = "Hello";
> greet = "Ciao"; // Ok?
>
> So the question is, enumerated values are constant?

There is a bug in DMD in which string literals are lvalues[1].
That is the problem you here have run into.


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


More information about the Digitalmars-d-learn mailing list