On Tue, Feb 03, 2026 at 06:11:52PM +0100, Grégory Vanuxem wrote: > Hello, > > I am wondering why I have this behavior, see the interpreter session below. > > I have a domain JLObjNamedTuple to operate on Julia NamedTuple, > something like a FriCAS Record. It contains two constructors with > declaration signature: > jntuple : String -> % > jntuple : Tuple(Any) -> % > > For comparaison, below, 'jobject(String)' has the same > declaration/definition than the first jntuple above: > jobject(str : String) == jlref str > > My problem is the function selection of jntuple(String). Here is an > interpreter session:
In some places interpreter recursively looks for all possiblities. But in many places once interpreter made a choice it sticks to it even if there is better/working possiblity. I suspect that what you see is caused by such premature commitment. Let ma add that design of algebra interface is affected by interpreter, current signatures a choosen to get reasonable behaviour from interpeter inference. For example, it would be natural to make more general matrix categories and such change seem to work fine for Spad. But interpreter has special case for current signatures, which doen not work for more general ones. In a bit different spirit, we do not export operation like 'nullSpace' over say PID-s, because current signatures force coercion to field of fractions, which is what normal users want. So, plan your signatures having in mind that _not_ exporting some signature or deliberatly using a differnt name can guide interpreter to good choice. > (1) -> jobject "(a=12,b=13)" > > Function Selection for jobject > Arguments: STRING > -> no appropriate jobject found in String > -> no appropriate jobject found in String > > Modemaps from Associated Packages > no modemaps > > Remaining General Modemaps > [1] Integer -> JLObject from JLObject > [2] String -> JLObject from JLObject > found good modemap for: jobject > String -> JLObject from JLObject > > [1] signature: STRING -> JOBJECT > implemented: slot (String) from JOBJECT > > > (1) (a = 12, b = 13) > Type: JLObject > Time: 0.07 (EV) + 1.69 (OT) = 1.76 sec > (2) -> jntuple "(a=12,b=13)" > > Function Selection for jntuple > Arguments: TUPLE(STRING) > -> no appropriate jntuple found in Tuple(String) > -> no appropriate jntuple found in Tuple(String) > > Modemaps from Associated Packages > [1] String -> JLObjNamedTuple from JLObjNamedTuple > [2] Tuple(Any) -> JLObjNamedTuple from JLObjNamedTuple > found good modemap for: jntuple > Tuple(Any) -> JLObjNamedTuple from JLObjNamedTuple > > [1] signature: TUPLE(ANY) -> JOBNTPL > implemented: slot (Tuple (Any)) from JOBNTPL > > > Function Selection for map by coercion facility (map) > Arguments: ((STRING -> ANY), LIST(STRING)) > Target type: LIST(ANY) > -> no appropriate map found in List(String) > -> no appropriate map found in List(Any) > -> no appropriate map found in Any > -> no appropriate map found in String > -> no appropriate map found in String > -> no appropriate map found in Any > > Modemaps from Associated Packages > [1] ((D4 -> D5),List(D4)) -> List(D5) from ListFunctions2(D4,D5) > if D4 has TYPE and D5 has TYPE > found good modemap for: map > ((D4 -> D5),List(D4)) -> List(D5) from ListFunctions2(D4,D5) > if D4 has TYPE and D5 has TYPE > > [1] signature: ((STRING -> ANY), LIST(STRING)) -> LIST(ANY) > implemented: slot (List (Any))(Mapping (Any) (String))(List > (String)) from LIST2(STRING,ANY) > > BoundsError: attempt to access Char at index [2] > > >> System error: > Invalid command given to Julia > > (2) -> jntuple (a=12,b=13) > > Function Selection for equation > Arguments: (VARIABLE(a), PI) > -> no appropriate equation found in Variable(a) > -> no appropriate equation found in PositiveInteger > -> no appropriate equation found in Symbol > -> no appropriate equation found in Integer > -> no appropriate equation found in Variable(a) > -> no appropriate equation found in PositiveInteger > -> no appropriate equation found in Symbol > -> no appropriate equation found in Integer > > Modemaps from Associated Packages > no modemaps > > Remaining General Modemaps > [1] (Symbol,Segment(D3)) -> SegmentBinding(D3) from SegmentBinding( > D3) > if D3 has TYPE > [2] (Symbol,String) -> QueryEquation from QueryEquation > [3] (D1,D1) -> Equation(D1) from Equation(D1) if D1 has TYPE > found good modemap for: equation > (D1,D1) -> Equation(D1) from Equation(D1) if D1 has TYPE > > [1] signature: (POLY(INT), POLY(INT)) -> EQ(POLY(INT)) > implemented: slot (Polynomial (Integer))(Polynomial (Integer)) > from EQ(POLY(INT)) > > > Function Selection for equation > Arguments: (VARIABLE(b), PI) > -> no appropriate equation found in Variable(b) > -> no appropriate equation found in PositiveInteger > -> no appropriate equation found in Symbol > -> no appropriate equation found in Integer > -> no appropriate equation found in Variable(b) > -> no appropriate equation found in PositiveInteger > -> no appropriate equation found in Symbol > -> no appropriate equation found in Integer > > Modemaps from Associated Packages > no modemaps > > Remaining General Modemaps > [1] (Symbol,Segment(D3)) -> SegmentBinding(D3) from SegmentBinding( > D3) > if D3 has TYPE > [2] (Symbol,String) -> QueryEquation from QueryEquation > [3] (D1,D1) -> Equation(D1) from Equation(D1) if D1 has TYPE > found good modemap for: equation > (D1,D1) -> Equation(D1) from Equation(D1) if D1 has TYPE > > [1] signature: (POLY(INT), POLY(INT)) -> EQ(POLY(INT)) > implemented: slot (Polynomial (Integer))(Polynomial (Integer)) > from EQ(POLY(INT)) > > > Function Selection for jntuple > Arguments: TUPLE(EQ(POLY(INT))) > -> no appropriate jntuple found in Tuple(Equation(Polynomial(Integer))) > -> no appropriate jntuple found in Tuple(Equation(Polynomial(Integer))) > > Modemaps from Associated Packages > [1] String -> JLObjNamedTuple from JLObjNamedTuple > [2] Tuple(Any) -> JLObjNamedTuple from JLObjNamedTuple > found good modemap for: jntuple > Tuple(Any) -> JLObjNamedTuple from JLObjNamedTuple > > [1] signature: TUPLE(ANY) -> JOBNTPL > implemented: slot (Tuple (Any)) from JOBNTPL > > > Function Selection for map by coercion facility (map) > Arguments: ((EQ(POLY(INT)) -> ANY), LIST(EQ(POLY(INT)))) > Target type: LIST(ANY) > -> no appropriate map found in List(Equation(Polynomial(Integer))) > -> no appropriate map found in List(Any) > -> no appropriate map found in Any > -> no appropriate map found in Equation(Polynomial(Integer)) > -> no appropriate map found in Equation(Polynomial(Integer)) > -> no appropriate map found in Any > > Modemaps from Associated Packages > [1] ((D4 -> D5),List(D4)) -> List(D5) from ListFunctions2(D4,D5) > if D4 has TYPE and D5 has TYPE > found good modemap for: map > ((D4 -> D5),List(D4)) -> List(D5) from ListFunctions2(D4,D5) > if D4 has TYPE and D5 has TYPE > > [1] signature: ((EQ(POLY(INT)) -> ANY), LIST(EQ(POLY(INT)))) -> LIST(ANY) > implemented: slot (List (Any))(Mapping (Any) (Equation > (Polynomial (Integer))))(List (Equation (Polynomial (Integer)))) from > LIST2(EQ(POLY(INT)),ANY) > > > (2) (a = 12, b = 13) > Type: JLObjNamedTuple > Time: 0.01 (IN) + 0.01 (OT) = 0.03 sec > =========================================================== > > Is this a bug in function selection? In the Modemaps list: > > Modemaps from Associated Packages > [1] String -> JLObjNamedTuple from JLObjNamedTuple > [2] Tuple(Any) -> JLObjNamedTuple from JLObjNamedTuple > > The first is the good one, no? > > I also noticed that the type of the argument is wrongly determined: > > (2) -> jntuple "(a=12,b=13)" > > Function Selection for jntuple > Arguments: TUPLE(STRING) > -> no appropriate jntuple found in Tuple(String) > -> no appropriate jntuple found in Tuple(String) > > If you have any idea... > > Greg > > -- > 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 [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/fricas-devel/CAHnU2dYd1yCx3LqU%2BgK3S_Ct9w1qNqYYfzMmaYC5CtF3rBTnOA%40mail.gmail.com. -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/aYIzbyz6YzMhdKNN%40fricas.org.
