On Feb 27, 2010, at 2:22 PM, Florent Hivert wrote:
Hi Robert,
You get the point. As far as I understand a RIF only return True
if the
interval are reduced to a single point. Is it right ? It would be
better
to
return a special value like Unknown than False. But that's another
question...
[...]
I certainly agree that 1-2 should be the general rule, I was just
pointing
out an exception. I like the idea of returning an Unknown object on
RIF
comparisons as well.
Not my idea. This was the way it worked in MuPAD. There was a three
state
boolean value, which was quite useful. Looking into python docs to
see if we
can have "and" and "or" work with a 3-state booleans, I found:
" A rich comparison method may return the singleton NotImplemented
if it does
not implement the operation for a given pair of arguments. By
convention,
False and True are returned for a successful comparison. However,
these
methods can return any value, so if the comparison operator is used
in a
Boolean context (e.g., in the condition of an if statement), Python
will call
bool() on the value to determine if the result is true or false. "
We do this to get symbolic equations.
Wouldn't it be mor meaningful to return NotImplemented ?
No. If a.__richcmp__(b) returns NotImplemented then b.__richcmp__(a)
is attempted (basically). Also, the value is truly unkownable, so
Unknowns is the right thing to return here.
- Robert
--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org