Enum alias members: yay or nay?
monarch_dodra
monarchdodra at gmail.com
Sun Sep 8 03:08:07 PDT 2013
On Sunday, 8 September 2013 at 09:43:02 UTC, Kenji Hara wrote:
> I also agree that the compiler enhancement is overkill.
>
> Kenji Hara
Let's not throw this away quite yet: There is *another*
fundamental difference:
enum S
{
a,
b = a,
}
This creates an enum with *two* entries.
enum S
{
a,
alias b = a,
}
This would create an enum with a *single* entry, which can be
accessed via two different names.
*This*, in itself, I think is a good idea. It helps distinguish
between "an enum that has multiple entries, some of which have
the same values" and "an enum whose entry 'a' can also be refered
to as 'b', fo rconvenience".
For starters, the distinction would be self documenting.
Second, once you involve things like `EnumMembers`, it becomes a
pretty interesting distinction to make.
I for one support this proposal (but not necessarilly for the
"counter" proposal: I think it is "a nice plus", but not an
essential feature).
More information about the Digitalmars-d
mailing list