DIPX: Enum Literals / Implicit Selector Expression
ryuukk_
ryuukk.dev at gmail.com
Thu Jun 30 11:32:42 UTC 2022
> Not saying I'm against the feature, I just don't understand why
> `auto color = Color.orange` is a problem and how `Color color =
> .orange` is better. Because of four fewer characters?
Indeed, this example doesn't make much sense, but the ony i
posted on the github shows exactly why we need it
```
set_my_flag( MySuperLongName.MyFlagA | MySuperLongName.MyFlagB |
MySuperLongName.MyFlagC | MySuperLongName.MyFlagD |
MySuperLongName.MyFlagE | MySuperLongName.MyFlagF );
```
vs
```
set_my_flag( .MyFlagA | .MyFlagB | .MyFlagC | .MyFlagD |
.MyFlagE | .MyFlagF );
```
One could argue to use ``with``
But what about places where it can't be used? and it is counter
productive, if the goal is to remove repetition, why introduce
more?
It already is explicit, and checked with the type system
I suggest trying languages that have that feature and see how
practical, and just better enums feel to use
I see myself still relying on constants to emulate enums... in
D, because of that, that's not good
More information about the Digitalmars-d
mailing list