DIPX: Enum Literals / Implicit Selector Expression

Dave P. dave287091 at gmail.com
Fri Dec 3 18:43:27 UTC 2021

On Friday, 3 December 2021 at 05:41:20 UTC, Rumbu wrote:
> On Thursday, 2 December 2021 at 19:44:07 UTC, russhy wrote:
>> could be implemented if we all agree that it would be a nice 
>> addition to the language!
>> Link: 
>> https://gist.github.com/RUSShyTwo/2fcf6d294d25ba748d61927b5eed2944
> In C# you can bring all enum members into scope with `using 
> static`
> [...]
> An equivalent D idiom will be
> ```d
> static alias MyEnum;
> ```
> [...]

The problem with this solution (and other `with` based solutions) 
is that it is effectively undoing a nice feature of D of sane 
namespaces. If you use a class or a struct, you don’t have to 
explicitly dump all of its member functions into your current 
scope. You just look up the symbol in the namespace of the 
struct/class. Similarly, a benefit of this proposal and how it 
works in Jai/Zig/Odin is that the compiler already knows what 
type it is expecting and so you are just looking up the name in 
the namespace of that type. No namespace pollution and it is very 

More information about the Digitalmars-d mailing list