Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1
ryuukk_
ryuukk.dev at gmail.com
Sat Nov 19 02:06:57 UTC 2022
On Saturday, 19 November 2022 at 01:04:39 UTC, Ki Rill wrote:
> On Friday, 18 November 2022 at 15:37:31 UTC, Mike Parker wrote:
>> ## Discussion Thread
>> [...]
>
> I think it's not worth adding this to D as well. I have no
> problem typing out the full name of an enum, and if I or anyone
> else does face such a difficulty, why not use a short alias?
>
> ```
> with(a, b, c, d):
> ```
> That's a good idea.
```D
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;
```
No need to import any helper function, no need to introduce any
extra noisy variable, no need to bloat the scope with `with` or
alias, it's simple, readable, and effective
Have you ever tried Vulkan? (graphics library)
The amount of ugly code one has to write due to verbose
enum/struct name is disgusting
Also D already supports designated initialization for structs,
it's kinda similar in principle, and it is super useful
More information about the Digitalmars-d
mailing list