This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The D Programming Language



> The difference from enums is that
> 
> 1. They don't implicitly cast to anything. I find that a source of bugs 
> with enums.
> 
> 2. They can't eventually end up having some undefined value, internally 
> represented as 42 or something. This can happen with enums.

Worse, it is explicitly legal in C++.  For example, there is nothing
wrong with: 'November | December' == 0x0c == nothing, which was an
explicit decision to preserve the validity of code that uses enums to
define bits.

This prevents compilers from optimizing or diagnosing invalid enum values.

-Tim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]