DIPX: Enum Literals / Implicit Selector Expression
Mike Parker
aldacron at gmail.com
Thu Jun 30 10:58:37 UTC 2022
On Thursday, 30 June 2022 at 10:51:31 UTC, ryuukk_ wrote:
>
>> auto color = orange;
>> // What is color?
>
> same, it's not ``.orange`` therefore it's 1, if it where with
> the dot, it's compile error telling you to be more explicit
>
>
>> auto color = cast(int)orange;
>> // What is color?
>
>
> it's not ``.orange`` therefore it is your variable, it if were
> with the dot, it'd take what ever is in the enum, then apply
> the cast
>
>
> I don't know it seems pretty obvious to me
>
> This feature is too good to not have
My problem with this is it is *not* obvious at all to me. When I
see `.foo`, I immediately think "foo is in the parent scope", as
that what is what it means right now in D. If we're suddenly
seeing `.foo` at module scope, now I've got a fault in my wiring;
`.foo` suddenly has different meanings depending on the scope in
which it's used.
I mean, maybe I could get used to it if I used it. But I don't
see myself using it at all.
Not saying I'm against the feature, I just don't understand why
`auto color = Color.orange` is a problem and how `Color color =
.orange` is better. Because of four fewer characters?
More information about the Digitalmars-d
mailing list