enhancing enums

Tomek Sowiński just at ask.me
Tue Dec 8 15:13:53 PST 2009


Dnia 08-12-2009 o 23:17:55 hehe45 <a3161739 at uggsrock.com> napisał(a):

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

Please no. I've done some C++ but the "need semicolon after brace?" is  
always something I need to think twice about.

> 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

D enums are already like that. Use with(EnumName) to get a temporary  
relief from prefixing constants with EnumName all the time.


Tomek



More information about the Digitalmars-d mailing list