[Python-3000] ABC for Inequalities
Guido van Rossum
guido at python.org
Tue Feb 12 19:02:25 CET 2008
On Feb 11, 2008 10:40 PM, Neil Toronto <ntoronto at cs.byu.edu> wrote:
> The problem is that, like all the binary operators, "orderable" is only
> defined for pairs of types. A single declaration of orderable-ness
> necessarily lacks information needed for type safety.
Actually, lots of languages have ways to express that the values of a
given type are orderable. E.g. in C++ you can create a template that
takes a single type argument which must define a total ordering using
'<'.
> Besides probably not being "worth it" (as you say), forcing the classes
> into an inheritance hierarchy doesn't seem Pythonic. (I may not have the
> Python-fu to make such declarations, but I'll call 'em as I see 'em.)
You're forgetting about virtual inheritance.
> Also, x objects and y objects may be orderable homogeneously, but not
> heterogeneously. I could impose a total order on sets of circles and
> another on sets of squares without imposing an order on sets of both
> circles and squares, and not be able to spell this under the inheritance
> approach.
Yes, that was what I explained at length.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list