PhobosWatch: manifest => enum

Janice Caron caron800 at googlemail.com
Sat Dec 29 06:42:44 PST 2007


On 12/29/07, Bruce Adams <tortoise_74 at yeah.who.co.uk> wrote:
> Why opAdd and not opIncrement?

There is no opIncrement().

There's only opPostInc(), which requires that its input be an lvalue.
Note that (x++) evaluates to x, not to x+1 (but x itself will be
incremented).

For rvalues, opAdd() is all you have.

In /real/ enumerations, the successor is (by definition) the next item
in the list. That is, given the enumeration { r, o, y, g, b, i v },
the successor of r is o, the successor of o is y, and so on, and this
will be true regardless of the underlying implementation (which the
application should neither know nor care). Of course, C, C++ and D
enums are not true enumerations, and we don't have successor nor
predecessor functions. The "trick" of figuring out a default
implementation value for the next element is just that.



More information about the Digitalmars-d mailing list