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

Paul Backus snarwin at gmail.com
Tue Nov 22 19:10:18 UTC 2022


On Tuesday, 22 November 2022 at 12:27:41 UTC, claptrap wrote:
> Why not an error if it's ambiguous? There are ways to specify 
> which you want if needed. And its probably unlikely enough that 
> occasionally having to specify the enum name is not anything to 
> be concerned about.

Error on ambiguity can break existing code. For example, this 
currently compiles, but would become ambiguous if we added enum 
type inference using .identifier syntax:

     enum E { x = 123 }
     int x = 456;
     static assert(.x == 456);

If we wanted to avoid breaking existing code, we would have to 
ensure that module-scope lookup *always* took precedence over 
enum member lookup.

Of course, the module scope .identifier syntax is not very widely 
used in the first place, so maybe a small risk of breakage is 
worth the benefit of nice syntax for enum members.


More information about the Digitalmars-d mailing list