On Apr 9, 8:16 pm, "didier deshommes" <[EMAIL PROTECTED]> wrote: > On Wed, Apr 9, 2008 at 10:18 PM, Carl Witty <[EMAIL PROTECTED]> wrote: > > > I'd like to reopen discussion of #2781, "bool() for SymbolicEquation > > should raise an error when it doesn't know the answer". Jason created > > a prototype patch to implement this, but gave up on it and closed the > > ticket when he was convinced that "this is not pythonic". > > > 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? > > -1 > I like bool(x>0) to be False by default if the answer is not known. > mhansen raised this great point that we rely so much on things like : > if (condition on x): > do something > > that it would be cumbersome to surround this statement with a try,catch block. > > I'm only opposing this because it is unpythonic but I don't see any > reason not to define methods that have the same functionality for > SymbolicEquation but *can* raise an exception when appropriate.
Conversely, we could have __nonzero__ (as used by bool() and if:) raise an exception and have another method (I suggest "known_true") that does not raise an exception; there would be no need for try/ except. In my opinion, the current behavior is too confusing (especially for non-expert users) to be worth keeping, even if it is occasionally useful. I'd guess that the majority of Sage scripts that use a SymbolicEquation as the condition in an if: statement do so incorrectly, as in the example from sage-support that I quoted above; even if it is used correctly, it's still going to be very confusing to a reader who may not be familiar with the unknown->False mapping. Also, I'm curious: when is it actually useful to use a SymbolicEquation as the condition of an if: statement (with the current meaning)? I hope I've never used this construct in my own code (I've certainly never done so intentionally, and I hope I haven't done so by accident). > didier 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 -~----------~----~----~----~------~----~------~--~---