On 1 October 2015 at 20:23, William Stein <wst...@gmail.com> wrote:
<SNIP>

By the way, look at how coercion "works" in Magma:
>
> $ magma
> Magma V2.18-5     Thu Oct  1 2015 16:59:12 on compute3-us [Seed =
> 629019987]
> Type ? for help.  Type <Ctrl>-D to quit.
> > R<x> := PolynomialRing(IntegerRing());
> > x + 1/2;
>
> >> x + 1/2;
>      ^
> Runtime error in '+': Bad argument types
> Argument types given: RngUPolElt[RngInt], FldRatElt


We are call this "complex coercion" in our Nemo discussions

[...as opposed to simple coercion:

 R, x = PolynomialRing(QQ, "x")
 K, a = NumberField(x^3 + 3x + 1,"a")

 a + 1/2 # simple coercion since the result lives in K
]

It's definitely quite easy to add complex coercion in Nemo/Julia (via Julia
generic catchall functions), but I'm resisting it quite obstinately for the
time being.

One reason is that it easily leads to functions that are not
type-consistent. You can quite easily write functions whose output type
depends on the values, rather than the types of the inputs. This completely
screws with type inference and Jit compilation, though Julia does allow it.

Since Nemo focuses on highly performant generics for the time being, I'm
trying to avoid introducing complex coercions, at least until we have a
very fast core. (Though naturally, mathematicians are keen to introduce
this feature as soon as possible, since it is basically germane to any real
mathematics.)

Bill.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to