DIP1044---"Enum Type Inference"---Formal Assessment

Jacob Shtokolov jacob.100205 at gmail.com
Wed Apr 26 11:52:31 UTC 2023


On Tuesday, 25 April 2023 at 20:15:39 UTC, ryuukk_ wrote:
> void set_connected()
> {
>     network_connect_state = NetworkConnectState.CONNECTED
> }
>
> MySuperLongNameFlag flag = MySuperLongNameFlag.A | 
> MySuperLongNameFlag.B | MySuperLongNameFlag.C | 
> MySuperLongNameFlag.D;
>
>
> set_flags(MySuperLongNameFlag.A | MySuperLongNameFlag.B | 
> MySuperLongNameFlag.C | MySuperLongNameFlag.D)

Okay, I understand this is sometimes really annoying, but in this 
example, why can't you just:

```d
import std.stdio;

enum MySuperLongNameFlag : int
{
     A = 0b0001,
     B = 0b0010,
     C = 0b0100,
     D = 0b1000,
}

void set_flags(MySuperLongNameFlag f) {}

void main()
{
     with (MySuperLongNameFlag)
     {
         auto flag = A | B | C | D;
         set_flags(A | B | C | D);

         writefln("%04b", flag);
     }
}

```




More information about the Digitalmars-d-announce mailing list