No we should not support enum types derived from strings
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue May 11 12:05:18 UTC 2021
On 5/10/21 8:19 AM, deadalnix wrote:
> On Monday, 10 May 2021 at 04:21:34 UTC, Andrei Alexandrescu wrote:
>> So you have a range r of type T.
>>
>> You call r.popFront().
>>
>> Obvioulsly the type of r should stay the same because in D variables
>> don't change type.
>>
>> So... what gives, young Padawan?
>>
>> No, this is not subtyping 101.
>
> If you have a range of T, then you got to return a T.
There's no return. The range is being mutated.
> I'm not sure
> what's the problem is here. Do you have a concrete example?
Of course. A range must implement popFront with the signature:
void popFront(ref SomeEnumString s) {
... please fill in the implementation ...
}
More information about the Digitalmars-d
mailing list