#15731: Too early coercion causes weird behavior of comparison
----------------------------+------------------------
       Reporter:  strenner  |        Owner:
           Type:  defect    |       Status:  new
       Priority:  major     |    Milestone:  sage-6.1
      Component:  coercion  |   Resolution:
       Keywords:            |    Merged in:
        Authors:            |    Reviewers:
Report Upstream:  N/A       |  Work issues:
         Branch:            |       Commit:
   Dependencies:            |     Stopgaps:
----------------------------+------------------------

Comment (by nbruin):

 Replying to [comment:3 strenner]:

 > This is not entirely true. From
 http://stackoverflow.com/questions/878943/why-return-notimplemented-
 instead-of-raising-notimplementederror (the same thing works for other
 comparison operators):

 I'm not sure it's entirely true; see
 [http://docs.python.org/2/reference/datamodel.html#object.__lt__] (the
 official documentation tends to be a little more authoritative than
 stackoverflow, and in the case of python, usually very clear too). Indeed,
 these methods can return to `NotImplemented`, but I think that leads
 python to try different variants, and never "swapped" (rather, it will try
 `__ge__` after `__lt__` has failed). The final showstopper is probably the
 older `__cmp__` protocol that predates python's "rich" comparisons and is
 actually what is used most throughout sage. I don't see a "notImplemented"
 escape documented for that. Normal python semantics seem to never swap LHS
 and RHS for comparison operators, contrasting what python specifies for
 `+` with `__add__` and `__radd__`

 > For instance, if Sage could override this built-in behavior and try
 coercion instead, that would save us from infinite recursion.

--
Ticket URL: <http://trac.sagemath.org/ticket/15731#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to