enhancing enums

Jeremie Pelletier jeremiep at gmail.com
Wed Dec 9 08:04:05 PST 2009


Lars T. Kyllingstad wrote:
> Jeremie Pelletier wrote:
>> hehe45 wrote:
>>> In c++ it is valid syntax to have trailing commas at the and of enum 
>>> definitions:
>>> enum {a, b, c, };
>>> This would be a useful addition to D too.
>>>
>>> The enum class syntax from c++0x should also adopted by D, this would 
>>> allow named enums which are not automatically encased by a namespace:
>>>
>>> enum EnumName {A, B, C};       ---> A, B and C are global constants
>>> enum class EnumName {A, B, C};---> A, B and C are in the EnumName 
>>> namespace
>>
>> I don't think that's necessary, you could simply do:
>>
>> typedef int EnumName;
>> enum : EnumName {A, B, C}
>>
>> And your global scope is happily polluted!
> 
> 
> Not any more. typedef will be removed from D2.
> 
> -Lars

Ah hmm, I missed that thread.

That was about the biggest use I had for typedefs, but this case can use 
aliases just as well.



More information about the Digitalmars-d mailing list