DIPX: Enum Literals / Implicit Selector Expression

TheGag96 thegag96 at gmail.com
Sun Jul 3 18:25:04 UTC 2022


On Friday, 1 July 2022 at 15:42:20 UTC, Steven Schveighoffer 
wrote:
> (Snip)

This is exactly how it should work. I think this is a pretty good 
feature. You want the strong typing, without namespace pollution, 
and without having to type everything out. It looks like the 
other C replacement languages see the value in it.

Ada of all languages actually works very similarly:

```ada
function foo is
   type thing is (a, b, c);
   type thang is (b, c, a);

   x : thing := a;
   y : thang := a; -- no ambiguity
begin
   -- ...
end foo;
```

We should learn a thing or two from Ada type features! Like using 
enums and ranges of enums as array bounds, for example. Ada is 
not a smooth language, but they somehow nailed stuff like this.


More information about the Digitalmars-d mailing list