PhobosWatch: manifest => enum

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 28 13:58:18 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. Such are in common use, and I've not 
> heard a complaint that it is very confusing. For example, it's in 
> std.c.windows.windows.d (among many), and there's not been a single 
> comment on it (pro or con) in 6 years in this n.g.

You missed the point of my example :)  I'm not debating anonymous 
enumerations and whether they should exist or not.  I'm saying that the 
definition of enum working like an enumeration, or working like a manifest 
list, based on whether the enumeration is named or anonymous, is confusing. 
If you look at the example, the type of the value changes from one version 
to the next, even though no type is specified.

> Extending it to allow heterogeneous types is not a big step, nor does it 
> break any existing code or usage.

Just because you can do something that changes the meaning of a keyword, 
especially to a meaning that is not described well by the english meaning of 
the word, and still have existing code compile, doesn't mean you should.

Having heterogeneous types in the same enum braces is a big step, because it 
fundamentally says 'enum is not an enumeration'.

-Steve 





More information about the Digitalmars-d mailing list