Design of reflective enums
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Mon Feb 19 09:06:11 PST 2007
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.
>
> In my opinion, for the reflective enums, the following constraint should apply:
> - they should 'look like' normal enums as much as possible.
Why? There is so much more freedom now, why limit ourselves. I think
enums of arbitrary types should be allowed, including arrays, hashes,
and user-defined types.
An enumerated type is nothing but a closed set of named values. The
names are always strings; the values can be of any (uniform) type.
Andrei
More information about the Digitalmars-d
mailing list