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

Dukc ajieskola at gmail.com
Sat Nov 19 08:33:50 UTC 2022


On Saturday, 19 November 2022 at 02:57:27 UTC, Walter Bright 
wrote:
> On 11/18/2022 6:06 PM, ryuukk_ wrote:
>> MySuperLongType flag = MySuperLongType.ValueA | 
>> MySuperLongType.ValueB | MySuperLongType.ValueC | 
>> MySuperLongType.ValueD | MySuperLongType.ValueE | 
>> MySuperLongType.ValueF | MySuperLongType.ValueG;
>> 
>> // vs
>> 
>> MySuperLongType flag = .ValueA | .ValueB | .ValueC | .ValueD | 
>> .ValueE | .ValueF | .ValueG;
>
> with (MySuperLongType)
> MySuperLongType flag = ValueA | ValueB | ValueC | ValueD | 
> ValueE | ValueF | ValueG;

Since with creates a new scope, it would have to be

```D
auto flag = { with(MySuperLongType) return
      ValueA | ValueB | ValueC | ValueD
      | ValueE | ValueF | ValueG;
}();
```

Still a lot better than repeating `MySuperLongType` for each 
member IMO, but ugly enough that this DIP would be an improvement.


More information about the Digitalmars-d mailing list