The Death of D1. (Was Tango vs Phobos)
Sean Kelly
sean at invisibleduck.org
Tue Aug 26 11:08:20 PDT 2008
superdan wrote:
> Robert Fraser Wrote:
>
>> superdan wrote:
>>> it's a big issue to me just in the opposite direction. the c enum is brain damaged. even dennis ritchie so much as acknowledged it. (and he won't budge on the definition syntax. so i guess that does mean somethin'.) the c++ enum grew one lonely neuron. problem is we got just used to the wrong. we won't blink an eye at
>>>
>>> enum { a = 1, b = 2 };
>>>
>>> but we get pissed at
>>>
>>> enum { a = 1.1, b = 2.5 };
>> I see the first as a problem, too. An enum is an _enumeration_.
>
> yeah. an enumerated type to be pedantic. as in, let me enumerate some stuff. i don't see an integer following from that.
That's fine. I'd be okay with enumerated types containing floating
point values, strings, whatever. But they should always have a name.
Using them to declare globally usable constants is just wrongheaded.
>> It
>> should not be abused for bitfields, masks, constants or anything else.
>
> that's not an abuse. it's just use.
>
> let me enumerate some math constants.
>
> enum math_constants
> {
> pi = 3.14,
> e = 2.71,
> avocado = 6.023e-23,
> }
>
> there was no abuse, your honor.
>
>> 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?)
>
> i am enumerating symbolic constants that logically belong together but don't have the same type.
Yeah, I see what you're saying. I'd say that it's logically a mis-use
of 'enum', but it does the trick.
>> - They can't be used as bitfields/masks (constants can be used for this
>> purpose)
>
> but enums are constants. so it looks like those doods got it all wrong because they have two concepts for the same thing.
I disagree. An enum is a constrained type. Each element of an enum
does happen to be a constant, but so what. More general constrained
types would be similar:
int[0..5] x; // an integer required to be between 0 and 5
Sean
More information about the Digitalmars-d
mailing list