#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 strenner):

 Replying to [comment:2 nbruin]:
 > How about `a<2`, `2<a` then? Do you want the same there? That would give
 an infinite recursion.

 I am hoping that there exists an implementation that avoids infinite
 recursion.

 > In python, the meaning of comparison is in the hands of the left hand
 side.

 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):

  "`NotImplemented` signals to the runtime that it should ask someone else
 to satisfy the operation. In the expression `a == b`, if `a.__eq__(b)`
 returns `NotImplemented`, then Python tries `b.__eq__(a)`. If b knows
 enough to return True or False, then the expression can succeed. If it
 doesn't, then the runtime will fall back to the built-in behavior (which
 is based on identity for == and !=)."

 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:3>
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