Should all enums be immutable?

Stewart Gordon smjg_1998 at yahoo.com
Tue Apr 5 16:05:57 PDT 2011


On 04/04/2011 10:07, Jonathan M Davis wrote:
> Enum values cannot be altered. It is an error to try and assign a value to an
> enum. However, the value of an enum isn't really const or immutable. It's
> copied every time that the enum is used. This is fine in cases where the enum
> is a value type, but it's problematic when the enum is a reference type. I
> believe that the classic example is if you have an AA which is an enum. You
> copy _the entire_ AA every time it's referenced. But it's not just AA's.
> Normal arrays have the problem too.
<snip>

There are a few bug reports about this:

http://d.puremagic.com/issues/show_bug.cgi?id=2237
http://d.puremagic.com/issues/show_bug.cgi?id=2331

Stewart.


More information about the Digitalmars-d mailing list