Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1

bauss jacobbauss at gmail.com
Tue Nov 22 09:37:43 UTC 2022


On Tuesday, 22 November 2022 at 05:55:04 UTC, rikki cattermole 
wrote:
> On 22/11/2022 6:47 PM, IchorDev wrote:
>> For instance, if everyone voted for "no syntax" then the poll 
>> would be useless to me.
>
> But it would tell you something useful.
>
> It would suggest a lot of people are wanting to explore 
> semantic behavior instead. Such as Walter's alternative 
> proposal idea.

If it's not implemented with .identifier then I will oppose it.

I don't buy the "it will break code" point of view either.

The only thing I can think of that will break is that .identifier 
already has a meaning today that means module scope.

But that could easily mean module AND "static/scoped" lookup and 
any ambiguity can be fixed by prioritization.

1. module scope 2. enum 3. static members of ex. classes

So if you type .a then it will first look in module scope, then 
in enums that are in scope and at last within classes that are in 
scope.

I suggested something like it earlier too.

Anything that is more complicated than .identifier is not worth 
it and will only introduce unncessary complexity to the language 
syntax.

Example:

```d
class A { static int a = 1; static int b = 2; }
enum B { b = 3, c = 4 }
int c = 5;

void main() {
   writeln(.a);
   writeln(.b);
   writeln(.c);
}
```

Prints:

1
3
5


More information about the Digitalmars-d mailing list