Design of reflective enums

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Mon Feb 19 09:11:16 PST 2007


renoX wrote:
> Michiel Wrote:
> 
>> renoX wrote:
>>
>>> Hello,
>>> Kevin Bealer has started an implementation (two implementations in fact!) of reflective enums, and I wanted to discuss the use case and the design of this feature to make it as useful as possible.
>>> Reflective enums have two useful properties that don't have normal enums:
>>> - their label is printable
>>> - it's possible to do a foreach on all the possible values.
>> By the way, should this not be in the core language?
> 
> Well I think that Ada does it in the core language (but I think that they are not printable), it is able to define enum as an index array as you suggest in your second email.
> As the more I look at D, the more I find it similar to Ada, it is perhaps a good idea to make them those enhanced enum in the core language, and as an improvement to Ada those enum should be printable (maybe as an option to save memory) .

On the contrary, I think it would be great if it were _not_ in the core 
language, and I'd be happy if a library enum was so good, it would cause 
deprecation of the built-in one.

Andrei



More information about the Digitalmars-d mailing list