>> I guess, "no coercion" is too drastic a change, but is there some nice >> way to restrict the types that are in scope and bring them in scope as >> they are needed? I'd rather like to type "import from Something" than >> having the interpreter apply a coercion I don't want. > > There was an idea to write up approaches to coercion together with the > sage community and especially with Nicolas Thiery. I think that would > be really good. > > Actually, I don't know whether they face similar difficulties.
I don't know whether it is the same in Sage, but in FriCAS we have the chance to decide wrt the full signature (i.e. input *and* output type). I guess Sage can only check input? Anyway, the idea is relatively nicely written up in Doye's thesis. http://axiom-portal.newsynthesis.org/refs/articles/doye-aldor-phd.pdf So basically the coerce functions must commute. Simple requirement, but important. In any case, inserting coercions here and there probably leads to a combinatorial explosion and ambiguity. Just assume you have written foo(bar(a,b), baz(c)) then in order to determine the return type, you have to take all functions foo that are in scope. If there are (at least) two different return types then you branch. Depending on whether you typematch in the left or the right branch, you can figure out what the return type might be. Now, the first problem is that there is a type match in both branches (without any coercion). What do you expect the interpreter to return? If it matches in one branch without coercion and in the other with coercion, which one is to take? If you decide for the branch with no coercion, are you sure that the user expected this? Automatic insertion of coercions is a heuristics in general. There is no way to satisfy everyone at the same time. The worst for me is that in general it will not be predictable what the interpreter will do for me. So writing a good specification is pointless. The outcome might even depend on the constructors that are currently in scope. Ralf -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
