On Tuesday, 1 March 2022 at 15:37:55 UTC, Ali Çehreli wrote:
On 3/1/22 07:19, Mike Parker wrote:
> On Tuesday, 1 March 2022 at 13:15:09 UTC, meta wrote:
>
>>
>>     enum Color
>>     { GRAY }
>>
>>     void setColor(Color color);
>>
>>     setColor(GRAY);
>
> Then that defeats the purpose of having named enums.

Yes and no.

meta is pointing at a difference between the above and the following:

  writeln(GRAY);

In the latter case, the compiler has no clue whether I intended to type GRAM. But in the former case, the type is Color. What remains is whether the compiler should be looking deep into Color and have a list of values to lower GRAY to Color.GRAY.

We heard this before for the switch statement: When the variable is Color, the case values can be accepted as Color as well (without the qualifier). (Yes, 'with' works as well, but the idea is the same.)

It feels the same for even int because we don't write int(42) when passing an int argument:

void foo(int) {}

foo(int(42));  // works
foo(42);       // works as well

So the lack of this compiler help does not bother me but still, I think the request is meaningful.

Ali

Yes, that's exactly the point I was trying to make, thanks Ali!

Reply via email to