PhobosWatch: manifest => enum

Bruce Adams tortoise_74 at yeah.who.co.uk
Sun Dec 30 16:39:27 PST 2007


On Mon, 31 Dec 2007 00:18:19 -0000, Sean Kelly <sean at f4.ca> wrote:

> Walter Bright wrote:
>> Sean Kelly wrote:
>>> err... make that unnamed and named.  One could argue that support for  
>>> unnamed enums is simply for ease of porting from C rather than because  
>>> it's a feature that really makes sense in a new language.  So making  
>>> it even more entrenched is undesirable.  But we need the feature and  
>>> if "enum" is it then...
>>  Right. Anonymous enums are already conventionally used not to declare  
>> enums, but a bunch of (not necessarily related) manifest constants. In  
>> fact, in C++ we see:
>>  template<> class factorial<1>
>> {
>>   public:
>>     enum { result = 1 };
>> };
>>  where anonymous enums are clearly used to declare manifest constants.
>
> Yup.  I simply find it troublesome that /conventions/ in C/C++ are being  
> used as justification for new language features in D.  For programmers  
> new to D who do not have a C/C++ background, I'm not sure I'd want to  
> resort to a history lesson when asked why 'enum', which is short for  
> 'enumeration' is used to signify manifest constants.
>
>
> Sean

As I've tried to point out before. Its not a 'convention' is a hack from
yesteryear. If you have a C++ compiler newer than 6 years old you should
use static const instead of enum for this.



More information about the Digitalmars-d mailing list