enum

Walter Bright newshound2 at digitalmars.com
Fri Apr 11 11:32:36 PDT 2014


On 4/11/2014 4:18 AM, Jonathan M Davis wrote:
> I don't see much point to enums if they're not intended to list
> all of their values.

Again, bit masks, Color, etc., and to provide a simple integral type that 
behaves like an integral type yet can be overloaded and type checked.

Andrei has pointed out that these uses are unsound if you desire that the 
enumeration lists all possible values, and he's right. But I don't think that 
automatically makes them pointless.

Heck, look at the "StorageClass" typedef in dmd's source code, and the list of 
STC macro definitions. That would make a nice D enum, and have some type safety 
too. It would be much more sound than the C method used.


More information about the Digitalmars-d mailing list