On Fri, Apr 23, 2010 at 11:07 PM, Nathan O'Treally <[email protected]> wrote:
> "[...] A coercion from one parent to another must be defined on the
> whole domain, and always succeeds. As it may be invoked implicitly, it
> should be obvious and natural (in both the mathematically rigorous and
> colloquial sense of the word). [...]"
> There are situations where I would relax that and raise an exception
> e.g. if a specific value can't be implicitly converted because it has
> no representation in the target domain.
> For "conversions" in Sage it is said that success might depend on the
> actual values (as opposed to their types).
I think one of the cases, we argued about it a lot (SD4 and later), is
whether the canonical partial map QQ --> GF(p) should be an
(automatic) coercion or not. This is for the "defined on the whole
domain" part.
Also, the "== doesn't fail" part seems to force this, since it would
be even more awkward to hide the coercion failure.
I'd rather have
sage: 1/3 == GF(3)(1)
raise a ZeroDivisionError, and
sage: 1/4 == GF(3)(1)
True
sage: 1/5 == GF(3)(1)
False
but others didn't agree with me.
You may have a point with the "exact domain" --> "inexact domain"
coercions being partial. I think the reasoning is that as long as you
only coerce from the exact domain into the inexact domain, there
shouldn't be problems. Also, inexact domains are NOT rings, so you
don't require the coercions to be ring homomorphisms.
With respect to NaN, it seems to me sage gets it wrong...
sage: 0.0/0.0 == 0.0/0.0
True
Gonzalo
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org