Le mardi 23 novembre 2010 à 12:57 -0500, Fred Drake a écrit :
> On Tue, Nov 23, 2010 at 12:37 PM, Antoine Pitrou <solip...@pitrou.net> wrote:
> > Enumerations aren't a type at all (they have no distinguishing
> > property).
> 
> In any given language, this may be true, or not.  Whether they should
> be distinct in Python is core to the current discussion.

I meant "type" in the structural sense (hence the parenthesis). enums
are just auto-generated constants. Since Python makes it trivial to
generate sequential integers, there's no need for a specific "enum"
construct.

Now you may argue that enums should be strongly-typed, but that would be
a bit backwards given Python's preference for duck-typing.

> From a backward-compatibility perspective, what makes sense depends on
> whether they're used to implement existing constants (socket.AF_INET,
> etc.) or if they reserved for new features only.

It's not only backwards compatibility. New features relying on C APIs
have to be able to map constants to the integers used in the C library.
It would be much better if this were done naturally rather than through
explicit conversion maps.
(this really means subclassing int, if we don't want to complicate
C-level code)

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to