On Sun, Jun 22, 2025 at 06:32:04PM +0200, 'Ralf Hemmecke' via FriCAS - computer algebra system wrote: > Hi Waldek, > > I just found another instance of an overlapping default implementations. > > In AbelianGroup > https://github.com/fricas/fricas/blob/master/src/algebra/catdef.spad#L34 > opposite?(x,y) == x = -y > > In AbelianMonoid > https://github.com/fricas/fricas/blob/master/src/algebra/catdef.spad#L75 > opposite?(x,y) == zero?(x + y)
Yes, the definition in AbelianGroup would not work in AbelianMonoid, so we need different definition. > While this looks computationally equally expansive, the problem certainly is > for functions that can be implemented more efficiently, in richer > structures. > > A few lines above > https://github.com/fricas/fricas/blob/master/src/algebra/catdef.spad#L29 > I find > > if not (% has Ring) then ... > > which does not really look attractive to me since it makes AbelianMonoid > depending on Ring and thus creating an actually needless circular > dependency. That is really not circular: default package of AbelianMonoid depends on Ring, but default package is different than AbelianMonoid and compilation of Ring does not depend on default package of AbelianMonoid. > Anyhow, the common understanding is still that it is **undefined** which of > the overlapping default implementations is actually used when a domain does > not explicitly implements that function, right? Well, there is search order which is defined, but probably it is unwise to depend in search order. You can depend on fact that strictly more specific definition will be choosen in preference to less specific one (but things get complicated when there are definitions uncomparable in generality). What is really undefined is overload resolution, that is decision which category declares given operation. When you look at operations in HyperDoc "Origin" is supposed to tell you this, but several origins may give matching signature and there is possibility for different types. -- 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/aFg8OC4k0k4xwkll%40fricas.org.