========================
Foo(R: Ring): Exports == Implementation where
Exports ==> Join(SetCategory, CoercibleFrom R) with
_*: (Integer, %) -> %
_*: (R, %) -> %
Implementation ==> add
((z: Integer) * (x: %)): % == (z::R) * x
((r: R) * (x: %)): % == ... -- actual implementation --
========================
AFAICS your code should compile as intended.
...
Namely, automatic coercions between % and Rep ...
Well, I believe that it works, but what I meant was not the problem
of (auto)coercion, but rather how the function selection works.
Clearly, the compiler will produce correct code for
*: (Integer, %) -> % and
*: (R, %) -> %
The problem arises what happens if R is set to Integer when I create the
domain.
Certainly the two functions (let's call them multINT and multR)
have both implementation code in the Foo constructor.
In Foo(Integer), there is however only *$Foo(Integer) with signature
(Integer,%)->%. Will this be the code for multR? Or will it be the code
for multINT which then calls (the not directly accessible code for) multR?
Clearly, one shouln't implement something like
((z: Integer) * (x: %)): % == x
((r: R) * (x: %)): % == -x
Or would it then be predictable or delibarately unspecified whether
17*x returns x or -x in Foo(Integer)?
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion visit
https://groups.google.com/d/msgid/fricas-devel/4ff6175f-b739-4148-a4fd-b3b29c57f191%40hemmecke.de.