enum
Dominikus Dittes Scherkl
dominikus.scherkl at continental-corporation.com
Fri Apr 11 05:13:18 PDT 2014
On Friday, 11 April 2014 at 10:07:13 UTC, Walter Bright wrote:
> The point being that D is powerful enough that you can use
> structs and templates to create all kinds of types with custom
> behaviors. They don't all need to be baked into the core
> language.
Yes, but it supports enum as a separate kind of types - but there
are two fundamental different usages of enums, for which a totaly
different set of operations is required:
1: "real" enums, that enumerate all possible values, that can be
used in final switch and that shouldn't allow for any kind of
arithmetic performed on them - not even increment (maybe a enum
count, but thats all)
2: types with some named constants, that should NOT be usable in
final switch but provide arithmetic, discontinual values and
everything what enum at the moment falsely provides.
So, D need not provide enums (both kinds can be build from
structs) but if it does, it should not unify them in ONE type.
There are too different expectations to enums as that one type
can satisfy them all. --> add a new type ("partial_enum" or
whatever) that can be used with arithmetics like flag-arrays or
COLOR, _and_ forbid the arithmetics for real enums.
More information about the Digitalmars-d
mailing list