I have a feature request: "Named enum scope inference"

Tommi tommitissari at hotmail.com
Fri Sep 28 19:31:48 PDT 2012


On Saturday, 29 September 2012 at 02:01:15 UTC, Alex Rønne 
Petersen wrote:
> The first issue with this proposal that comes to mind is this:
>
> enum Foo { bar }
>
> void func(Foo f)
> {
>     // ...
> }
>
> // ...
>
> Foo bar = Foo.bar;
> func(bar); // ?

Maybe it should simply throw a compile error about the ambiguity 
of 'bar' in 'func(bar)'. But if the local variable 'bar' if not 
of Foo type, then there's no ambiguity. Or, if the local variable 
'bar' is a compile time constant that evaluates to Foo.bar, then 
there's no ambiguity either.


More information about the Digitalmars-d mailing list