[Aldor-l] Collapse of function signatures

Ralf Hemmecke hemmecke at risc.uni-linz.ac.at
Tue Jan 4 06:01:56 EST 2005


Hi Christian,

>>>> In DistributedMultivariatePolynomial1(R, V, E) there are two functions
>>>>        *: (Integer, %) -> %
>>>>        *: (R, %) -> %

> Nevertheless I fully agree, that it might be a good idea to give the  
> developer some way to assist the compiler in "choosing the most  
> sppropriate implementation" for a function signature if more  
> implementations are available.
> At present state, it is tricky (although possible) to "inherit" the  
> desired functions.

Oh, let me guess. I say

#include "algebra"
extend DistributedMultivariatePolynomial1(
   R: Ring,
   V: VariableType,
   E: ExponentCategory(V)
): with {
   myItimes: (Integer, %) -> %;
   myRtimes: (R, %) -> %;
} == add {
   myItimes(i: Integer, x: %): % == i*x;
   myRtimes(r: R, x: %): % == r*x;
}

and later I use myItimes instead of * if I want to make sure that the 
Integer version is used by the compiler. I wonder whether the compiler 
behaves as I expect or whether it is smart enough to optimize myItimes 
away so that the whole extension becomes useless.

I don't know if that is what you meant, but the above code would not 
help for the bug in xxx.as from 
http://www.aldor.org/pipermail/aldor-l/2004-December/000001.html, 
because there I multiply two polynomials. And it might happen during a 
long computation that I even don't know in advance when the variable a 
will be equal to one. I cannot simply turn a: A into a: Integer and use 
myItimes from above.

I've just put the above code into dmp.as, added

#library DMPExtension "dmp.ao"
import from DMPExtension;

to xxx.as and said

aldor -fao -fo -q5 dmp.as
aldor -grun -lalgebra -laldor -DC1 xxx.as
"xxx.as", line 18:         x: A := monomial(exponent(1,0,0)$E)$A;
                    .........................^
[L18 C26] #1 (Error) Argument 1 of `monomial$A' did not match any 
possible parameter type.
     The rejected type is E.
     Expected type E.

Looks like another compiler bug.

Ralf



More information about the Aldor-l mailing list