On Sun, 11 Feb 2007 23:38:37 -0800, Michel <[EMAIL PROTECTED]> wrote:

>
> I am wondering what Sage's strategy is with regard to coercions.

There are two versions of coercion:

    1. implicit canonical coercion (the _coerce_ method),

    2. coerce if there is any way that makes any reasonable sense (never done 
implicitly),
       which is the __call__ method.

Your example below falls under (2), and it would be fine to allow it.
Probably the best choice for the coercion in this case would be to take
the midpoint of the interval.  That this doesn't work yet is simply because
nobody has implemented it and sent me a patch.

I don't think there should be an implicit canonical coercion (1) in this
case, since then the sum of an interval and real number would be ambiguous.

> It thought that it would be reasonable that an element of a
> RealIntervalField
> should be coercable into a RealField but this does not seem to be the
> case.
>
> sage: r=RealIntervalField(16)((1,2))
> sage: RealField(16)(r)
>
> <type 'exceptions.TypeError'>: Unable to convert x
> (='[1.00000...2.00000]') to real number.
>
> Is this a design decision?

William

--~--~---------~--~----~------------~-------~--~----~
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://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to