No we should not support enum types derived from strings

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Thu May 13 06:59:25 UTC 2021


On Thursday, 13 May 2021 at 02:43:41 UTC, Jonathan M Davis wrote:
> On Wednesday, May 12, 2021 8:13:04 PM MDT Jonathan M Davis via 
> Digitalmars-d wrote:
> Or more accurately, all operations on an enum which are not 
> guaranteed to result in a valid enum value should result in the 
> base type (and thus not be assignable to a variable of that 
> enum type without a cast), and operations which mutate the enum 
> should not be allowed unless they're guaranteed to result in a 
> valid enum value. But regardless, the point is that ideally, 
> unless a cast is used, it should be impossible to have 
> something typed as an enum without it being guaranteed that the 
> value be one of the enumerated values for that enum type. But 
> that's definitely not how D enums work...
>
> - Jonathan M Davis


So basically enum should implicitly be declared to be immutable 
right?


More information about the Digitalmars-d mailing list