On Tue, Apr 01, 2025 at 09:27:38AM +0200, 'Ralf Hemmecke' via FriCAS - computer 
algebra system wrote:
> > > ========================
> > > 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?

Currently Spad compiler selects a number for each exported signature.
Calls inside domain are based on those numbers.  In particular
multINT will always (regardless of R) call multR.  For calls from
outside it is really not well defined which one will be called
when R = Integer.

-- 
                              Waldek Hebisch

-- 
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/Z_AhbMKjs6F0hE-A%40fricas.org.

Reply via email to