Dear Waldek,
suppose I write a domain as follows:
========================
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 --
========================
I wonder whether I should actually do this.
Does the compiler really produce proper code for Foo(Integer)?
I fear that the compiler might think that implementing
((z: Integer) * (x: %)): %
it, it just needs to call coerce(z)@Integer and then generate code
for (coerce(z)@Integer)*x) basically leading to an infinite loop.
Can the compiler handle that case or must I be more careful with that
definition?
I guess the original designers have thought about this problem and
solved it somehow, but maybe not.
Actually, code like in Foo appears in the library, for example, here
https://github.com/fricas/fricas/blob/master/src/algebra/fr.spad#L222
and here
https://github.com/fricas/fricas/blob/master/src/algebra/pfr.spad#L294
and that does not seem to be a problem.
Thank you in advance.
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/d940e597-e47b-4364-b223-393bf4a60ec8%40hemmecke.org.