The Death of D1. (Was Tango vs Phobos)

Sean Kelly sean at invisibleduck.org
Tue Aug 26 11:01:19 PDT 2008


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_. 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.
> 
> 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_.

Right.  I simply disagree with the suggestion that a label is a label 
and we should forget about it and move on.  If a word is used to 
represent something then the representation should be consistent with 
the meaning of the word, not some outdated convention from a language 
where the feature is considered a mistake anyway.  I'd prefer to take 
the long view... when teaching D to college students in 10 years, what 
kind of answer is "well, it derives from a broken convention in a 
language you've never heard of" to the question "why does D use 'enum' 
to represent manifest constants?"  However, I realize this will never 
change so I'll suppress my angst and move on ;-)


Sean



More information about the Digitalmars-d mailing list