Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Tue Nov 22 01:22:53 UTC 2022


On 22.11.22 01:42, Walter Bright wrote:
> On 11/20/2022 8:25 AM, IchorDev wrote:
>> If you're sure that arithmetic and ETI won't mix for implementation 
>> reasons then I could explicitly prohibit it. My only apprehension is 
>> that `OR`ing enum flags with ETI is very handy.
> 
> It is handy and used a lot.

The way D does it, it also has some issues:

enum E{
     a=1,
     b=2,
}

void main(){
     import std.stdio;
     writeln(E.a|E.b); // cast(E)3
}

Some other languages require some annotation on the enum to indicate 
that it is to be used as flags and disallow arithmetic otherwise, 
writeln could pick that up also and format it nicely as a|b.


More information about the Digitalmars-d mailing list