[Aldor-l] Collapse of function signatures
Ralf Hemmecke
ralf at hemmecke.de
Fri Dec 31 15:09:55 EST 2004
Hello,
Look at the attached code foo.as.
There are two functions foo.
Unfortunately, their signatrues become indistinguishable for
Poly(MachineInteger). The compiler has no way to find out which foo(1) I
actually mean inside main(), so it takes the first one it finds. (Or can
I help the compiler somehow?)
In this little domain, it is easy to find out what will happen. But how
can one predict the result
- if one of the foo's is defined in another domain, or
- if only one foo is actually defined for Poly(R) and the other one is
added by an 'extend', or
- if foo appears in a category default?
In DistributedMultivariatePolynomial1(R, V, E) there are two functions
*: (Integer, %) -> %
*: (R, %) -> %
The first is implemented in sm_dmp1.as and the second in sm_dmp0.as.
Fortunately, they do not contradict.
Since the Aldor compiler still produces segfaulting code for 1*x (see
xxx.as), I wonder whether it gets confused for R=Integer by the
existence of one implementation in DistributedMultivariatePolynomial1
and the other in DistributedMultivariatePolynomial0. This guess is
supported by the code in xxx.as.
I agree that for efficiency reasons two * functions make sense, but I
would rather like that the semantic is made more explicit. For my foo.as
example, I would like that the more specific implementation is dominant.
So the output should always be [-1].
I know my wish is not easy to achieve, since one could have cases like
bar: (R, MachineInteger) -> %
bar: (MachineInteger, R) -> %
but no
bar: (MachineInteger, MachineInteger) -> %
Could the compiler at least warn if there is an _obvious_ collapse of
two function signatures, like with Integer or MachineInteger?
Ralf
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: foo.as
Url: http://aldor.org/pipermail/aldor-l_aldor.org/attachments/20041231/3ed8794d/attachment.ksh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: xxx.as
Url: http://aldor.org/pipermail/aldor-l_aldor.org/attachments/20041231/3ed8794d/attachment-0001.ksh
More information about the Aldor-l
mailing list