The purpose of this page is to begin the process of documenting the function selection process used by the FriCAS interpreter. *On [Axiom-developer] 27 Jan 2008 11:14:39 +0100 Martin Rubey wrote:* ## How does the interpreter choose signatures?Consider this example: spad )abb package TEST Test Test(): with spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2081003860582365004-25px001.spad using old system compiler. TEST abbreviates package Test ------------------------------------------------------------------------ initializing NRLIB TEST for Test compiling into NRLIB TEST compiling exported foo : Fraction Integer -> Fraction Integer TEST;foo;2F;1 is replaced by n Time: 0.01 SEC. fricas )set mess selection on
Type: PrimeField?(5)Note that the interpreter seems to prefer Now consider: fricas )set mess selection off fricas )set mess selection on fricas )set mess time on
fricas Time: 0.01 (IN) + 0.07 (EV) + 0.16 (OT) = 0.24 sec fricas )set mess time off There are many things I do not understand: - why doesn't the interpreter choose the "General Modemap":
[8] (Fraction Polynomial D4,SegmentBinding OrderedCompletion Fraction Polynomial D4) - why is its preference different now? I.e., in package
`DEFINTRF` , it seems to prefer`(FRAC POLY INT,SEGBIND ORDCOMP EXPR INT)` over '(FRAC POLY INT,SEGBIND ORDCOMP FRAC POLY INT)':[1] signature: (EXPR INT,SEGBIND ORDCOMP EXPR INT) -> Union(f1: ORDCOMP EXPR INT,f2: LIST ORDCOMP EXPR INT,fail: failed,pole: potentialPole) implemented: slot (Union (: f1 (OrderedCompletion (Expression (Integer)))) (: f2 (List (OrderedCompletion (Expression (Integer))))) (: fail failed) (: pole potentialPole))(Expression (Integer))(SegmentBinding (OrderedCompletion (Expression (Integer)))) from DEFINTEF(INT,EXPR INT) [2] signature: (FRAC POLY INT,SEGBIND ORDCOMP EXPR INT) -> Union(f1: ORDCOMP EXPR INT,f2: LIST ORDCOMP EXPR INT,fail: failed,pole: potentialPole) implemented: slot (Union (: f1 (OrderedCompletion (Expression (Integer)))) (: f2 (List (OrderedCompletion (Expression (Integer))))) (: fail failed) (: pole potentialPole))(Fraction (Polynomial (Integer)))(SegmentBinding (OrderedCompletion (Expression (Integer)))) from DEFINTRF INT [3] signature: (FRAC POLY INT,SEGBIND ORDCOMP FRAC POLY INT) -> Union(f1: ORDCOMP EXPR INT,f2: LIST ORDCOMP EXPR INT,fail: failed,pole: potentialPole) implemented: slot (Union (: f1 (OrderedCompletion (Expression (Integer)))) (: f2 (List (OrderedCompletion (Expression (Integer))))) (: fail failed) (: pole potentialPole))(Fraction (Polynomial (Integer)))(SegmentBinding (OrderedCompletion (Fraction (Polynomial (Integer))))) from DEFINTRF INT - why does it prefer DEFINTEF(INT,EXPR INT) over DEFINTRF INT ?
There is a function In the case of foo$TEST, they are: |cost: | (((|Test|) (|Expression| (|Integer|)) (|Expression| (|Integer|))) ((|Expression| (|Integer|)) (|Expression| (|Integer|))) (NIL)) 53600 |cost: | (((|Test|) (|Fraction| (|Integer|)) (|Fraction| (|Integer|))) ((|Fraction| (|Integer|)) (|Fraction| (|Integer|))) (NIL)) 52500 |cost: | (((|Test|) (|PrimeField| 5) (|PrimeField| 5)) ((|PrimeField| 5) (|PrimeField| 5)) (NIL)) 51500 I do not understand yet how cost is assigned to the various signatures, but the results look slightly fishy to me... Here is the code for `i-funsel.boot` . We can make changes by
clicking `edit` here and then test them later in this page by
clicking on `Preview` .
For example see changes marked ## New Selection of ModemapsThese notes were provided as comments in the original source (from FriCAS). - selection of applicable modemaps is done in two steps:
first it tries to find a modemap inside an argument domain, and if this fails, by evaluation of pattern modemaps - the result is a list of functions with signatures, which have the
following form:
[sig,elt,cond] where sig is the signature gained by evaluating the modemap condition elt is the slot number to get the implementation cond are runtime checks which are the results of evaluating the modemap condition - the following flags are used:
$Coerce is NIL, if function selection is done which requires exact matches (e.g. for coercion functions) if $SubDom is true, then runtime checks have to be compiled
boot SETANDFILEQ($constructorExposureList, |