DIPX: Enum Literals / Implicit Selector Expression

ryuukk_ ryuukk.dev at gmail.com
Thu Jun 30 12:02:15 UTC 2022


On Thursday, 30 June 2022 at 11:53:16 UTC, Mike Parker wrote:
> I'd rather see an enhancement to `with` that would allow it in 
> declarations. Just off the top of my head, something like:
>
> ```d
> with(.MyFlags) flags = A | B | C;
> ```
>
> That would not create a scope, and it would have to be usable 
> in module-scope initializers. `with` already means "prefix this 
> type to fields that fit". Here it just goes one step further 
> and allows for the type of the declaration to be inferred.

This is not as clean as just this:

     MyFlags flags = .A | .B | .C | .D | .E | .F;


I feel it's much easier to read, there is no noise

Maybe the improvement of with could come handy when pairing it 
with ```auto`` uses where the typesystem can't guess what you 
give it to him

But they are different features, both are valid imo


More information about the Digitalmars-d mailing list