PhobosWatch: manifest => enum
Janice Caron
caron800 at googlemail.com
Sat Dec 29 19:41:40 PST 2007
On 12/30/07, Bruce Adams <tortoise_74 at yeah.who.co.uk> wrote:
> Surely that is what we mean with an enumeration. We allow successor (and
> optionally predecessor)
> operations to cycle through the entities in a particular order but adding
> them is unnatural.
In a true enumeration, it isn't that unreasonable to equate ++ or +1
with the successor function, and -- or -1 with the predecessor
function.
Given that, for an enum type E, what you want to allow is
E opAdd(int)
E opSub(int)
but you want to disallow
E opAdd(E)
E opSub(E)
So to use your example:
Colour c2 = red+green; //WRONG
Colour c2 = red+2; //OK
the latter meaning the successor of the successor. Of course D enums
aren't true enums, so we might end up having to allow "red+green" by
accident. :-)
More information about the Digitalmars-d
mailing list