axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Internal Error : Interpreter code generation fail


From: Bill Page
Subject: Re: [Axiom-developer] Internal Error : Interpreter code generation failed for expression...
Date: Tue, 21 Jul 2009 19:08:57 -0400

On Tue, Jul 21, 2009 at 10:46 AM, Ralf Hemmecke wrote:
>>     Ok,  but can you explain, why Axiom can compile test2 ?
>>
>>        the only difference is line
>>                      n(i,j) := fallingPower(i+j,j)  in test0
>>        and
>>                      n(i,j) := fallingPower(i,j)  in test2
>
> Well my guess is that because
>
> fallingPower (p,0) == 1
> fallingPower (p,n) == p*fallingPower(p-1,(n-1)::NNI)
>
> is a recursive definition.
>
> Otherwise, I have no idea.
>

There is nothing wrong with using a recursive definition for
'fallingPower'. Obviously Axiom should not fail with an "Internal
Error" in any case. That is clearly a bug.

I have no simple explanation about why test2 compiles successfully,
but notice that the domain NNI does not contain '-' as an operation,
so by writing

  fallingPower : (INT,NNI) -> INT
  fallingPower (p,n) == p*fallingPower(p-1,n-1)

you are actually forcing the interpreter to add some hidden automatic
conversions (coercions). It must coerce 'n' to 'Integer', do the
subtraction and then convert (retract) the result back to
NonNegativeInteger. This second conversion might not be possible.
Apparently in anything but the trivial case in-lining of this function
fails and that is a bug.

You might notice that something complicated is going on even in the
case of 'test2' because of the warning:

   Compiling function G1997 with type Integer -> Boolean

But if you simply omit the declaration, e.g. comment it out

  -- fallingPower : (INT,NNI) -> INT

then you see that Axiom actually assumes (Integer,Integer) -> Integer,
 no coercions are necessary and the code generation succeeds.

Regards,
Bill Page.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]