PhobosWatch: manifest => enum

James Dennett jdennett at acm.org
Fri Dec 28 15:52:36 PST 2007


Walter Bright wrote:
> Steven Schveighoffer wrote:
>> Consider this:
>>
>> enum Foo { x = 'a' }
>>
>> Now we remove Foo:
>>
>> enum { x = 'a' }
>>
>> Now x is a char, where Foo.x was an int?  That is very confusing.
> 
> C, C++, and D already work that way.

No, they don't.  In C, x has integral type, whether the enum is
named or not.  In C++, x is *not* an int, but rather its type is
an enum type (named or not).  Naming the enum type does not
affect the type of x in C or C++.

(The fact that C says that 'a' is an int and C++ says that it is
a char is a separate issue.)

> Such are in common use, and I've
> not heard a complaint that it is very confusing. 

It apparently confuses D's designer -- what chance do us mere
mortals have?!

-- James



More information about the Digitalmars-d mailing list