No we should not support enum types derived from strings

Walter Bright newshound2 at digitalmars.com
Wed May 12 01:06:29 UTC 2021


On 5/11/2021 5:04 PM, Andrei Alexandrescu wrote:
> Another unpleasant issue:
> 
>      enum Y : string { f7 = "%d" }
>      writeln(typeof(Y.f7.representation).stringof);
> 
> prints immutable(ubyte)[], not immutable(char)[]. So not even 
> Y.f7.representation is usable. Sigh.

The representation of a named enum is its base type.

The representation of a string type is immutable(ubyte)[].

It's consistent.


More information about the Digitalmars-d mailing list