No we should not support enum types derived from strings
Imperatorn
johan_forsberg_86 at hotmail.com
Wed May 12 04:06:34 UTC 2021
On Wednesday, 12 May 2021 at 02:56:49 UTC, Walter Bright wrote:
> On 5/11/2021 7:04 PM, deadalnix wrote:
>> On Wednesday, 12 May 2021 at 01:06:29 UTC, Walter Bright wrote:
>>> 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.
>>
>> Y.f7 is of type Y. It's representation is string, not
>> immutable(ubyte)[]
>>
>> typeof(Y.f7.representation) ought to be string.
>> typeof(Y.f7.representation.representation) ought to be
>> immutable(ubyte)[]
>
> That's what I said.
🍿
More information about the Digitalmars-d
mailing list