[Python-ideas] PEP for enum library type?
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Feb 22 05:59:10 CET 2013
MRAB wrote:
> On 2013-02-21 23:24, Greg Ewing wrote:
>
>> For example, enums in
>> Pascal are definitely distinct types from integers, yet the language
>> explicitly assigns them ordinal values and defines an ordering for
>> them. Wirth must have thought there was a benefit in doing that.
>
> It means that sets of enums can be implemented using bitsets.
That could still have been done without exposing the ordinal
values. Yet, Pascal provides an ord() function.
I suppose one viewpoint might be that as long as there is
a defined ordering, there's always going to be at least an
implied mapping to natural numbers, so there's not much
point in trying to hide it.
--
Greg
More information about the Python-ideas
mailing list