enum

Dominikus Dittes Scherkl dominikus.scherkl at continental-corporation.com
Thu Apr 10 10:09:52 PDT 2014


On Thursday, 10 April 2014 at 14:37:37 UTC, Meta wrote:
> On Thursday, 10 April 2014 at 04:47:31 UTC, Walter Bright wrote:
>> It makes perfect sense if you think of an enum as an integral 
>> type, some values of which have names, as in the "Color" 
>> example I posted earlier.
>
> I do not wish to think of enums in this way. Your use-case is 
> better solved with Typedef and a struct.

Me neither. An enumeration should exactly do this: enumerate each 
of it's possible values. If you like to do arithmetics on it, 
it's something different. Especially flags and colors are NOT 
enumerated - you give only some names for some edge cases. So why 
not call it such: "named examples" and make it a differnt type, 
where arithmetic is allowed and "final switch" is not (like for 
int)?
Especially this is what is really annoing, and a "default" case 
is not even allowed in a final switch - so it should also not be 
possible to construct illegal values other than by explicit 
unsave operations (like cast).


More information about the Digitalmars-d mailing list