[Pyrex] More on enums in 0.9.5.1a
Eric Huss
e-huss at netmeridian.com
Tue Feb 6 20:24:43 UTC 2007
Enum strictness seems to be a little too extreme in 0.9.5.1a. Arithmetic
operations should be allowed on enums. As far as my reading of the C++
standard, and reading from Stroustrup (The C++ Programming Language),
enums are implicitly converted to integers for arithmetic operations.
Also, implicit casts from enum->int are ok, such as in assignment (but the
inverse is not). I believe the following errors in Pyrex should be
allowed:
cdef enum Color:
red
white
blue
cdef Color e
cdef int i
i = red # Fails.
i = red + 1 # Fails.
i = red | 1 # Fails.
e = white
i = e # Fails.
i = e + 1 # Fails.
-Eric
More information about the Pyrex
mailing list