On Apr 10, 1:41 am, Simon King <[EMAIL PROTECTED]> wrote:
> On Apr 10, 4:18 am, Carl Witty <[EMAIL PROTECTED]> wrote:
>
> > I like the "raise an exception" behavior, because it would eliminate
> > questions asking why form1 and form2 below are different (from this
> > sage-support 
> > threadhttp://groups.google.com/group/sage-support/browse_thread/thread/79d0...).
> > (I have seen this exact problem at least twice on sage-support.)  What
> > do you think?
>
> I guess what i suggest wouldn't solve the plot-issue. However, i think
> if one doesn't know whether an inequality holds, or if the inequality
> simply makes no sense (such as in the case of an unordered field) then
> bool() should neither raise an exception nor return False but return
> None. I think it is much simpler to have

bool() is a Python builtin that cannot return None.  bool(x) calls
x.__nonzero__(); but if you try to make __nonzero__() return None, you
get:
<type 'exceptions.TypeError'>: __nonzero__ should return an int

Chris's suggestion of making if: sometimes return an "unevaluated if"
is also impossible in Python.

Of course, we can (and probably should) make a new method on
SymbolicEquation that returns True/False/None; we could also add
support for a symbolic "unevaluated if" if we wanted.  But since we
use Python, we're stuck with: bool(x > 0) must return True, False, or
raise an exception; and this controls what "if x > 0:" will do.

Carl


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to