The Death of D1. (Was Tango vs Phobos)
Christopher Wright
dhasenan at gmail.com
Mon Aug 25 17:56:41 PDT 2008
Robert Fraser wrote:
> I see the first as a problem, too. An enum is an _enumeration_. It
> should not be abused for bitfields, masks, constants or anything else.
> Look at how it's used in Java/C# (ignoring the fact that Java's enum is
> actually syntactic sugar for a class...):
>
> - Only named enums are supported (otherwise, what are you enumerating?)
> - They can't be used as bitfields/masks (constants can be used for this
> purpose)
> - You can't define them as arbitrary values.
Take C# this example from my job:
[Flags] // hint to the compiler: treat it as a bitfield
public enum DaysOfWeek
{
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
Friday = 16,
Saturday = 32,
Sunday = 64,
None = 0,
All = 127
}
DaysOfWeek weekends = DaysOfWeek.Saturday | DaysOfWeek.Sunday;
> In D, it's all water under the bridge and it's just a keyword; it
> doesn't matter that much. That being said, it's still a bad selection of
> keyword IMO and there's no argument that's going to convince me that
> `enum string CRLF = "\r\n";` is somehow an _enumeration_.
You wouldn't get to the keyword "enum" just from the definition of
"enumeration". But it's not too far from the previous usage.
More information about the Digitalmars-d
mailing list