operator overloading

david_ullrich at my-deja.com david_ullrich at my-deja.com
Tue Jun 6 13:09:48 EDT 2000


In article <oqwvk2df1q.fsf at titan.progiciels-bpi.ca>,
  =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard at iro.umontreal.ca> wrote:
> david_ullrich at my-deja.com writes:
>
> > This reminds me of a question that I've never got around to asking:
Are
> > there implicit requirements on __cmp__, like the order it defines
has
> > to be transitive, __cmp(a,b)__ has to be the opposite of
__cmp(b,a)__, etc?
>
> If one wants tools like `sort()' to work properly, `__cmp__' should
establish
> a proper order relation, yes.  Otherwise, rather cryptic bugs might
pop out.

    Presumably. If so this should probably be mentioned in the docs.
(I recall once long ago trying to get a bug from a non-transitive
__cmp__, and failing. But I didn't try very hard...)

> However, to give a special meaning to `<=', say, one might surely play
> tricks and not use `__cmp__' as it was meant to be.  A butterfly is
surely
> free to travel nearby a fire :-).

    Heh-heh. I guess I'm getting old - things like using __cmp__
in unusual ways don't thrill me the way they used to.

DU

> --
> François Pinard   http://www.iro.umontreal.ca/~pinard
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list