compilation of tail recursive functions



>>>>> "Volker" == van Nek <van.Nek at gmx.net> writes:

    Volker> My interest is concentrated on the compilation
    Volker> behaviour. What does clisp do, when you compile n-sum-1? 
    Volker> Is there a tail recursive optimization?

I think that with Common Lisp, you can't depend on tail recursion
happening, unlike Scheme.  So even if it were tail-recursive, the
implementation doesn't have to take advantage of that.  Of course, I
think just about all Common Lisp implementations will do that for the
simpler cases.

    Volker>         (T ;(SIMPLIFY 
    Volker>                (MFUNCTION-CALL $N_SUM_1 (ADD* $N -1) (ADD* $N $RES))))));) 

    Volker> The translation is done by Maxima. So I expect, that you have the same code and I  
    Volker> expect, that clisp will not optimize too. 

I'd have to look at the translator to see why the call to simplify is
there.  However, even with the interpreted code, simplification is
done on each recursive call, right?  If so, the compiled code needs to
preserve that behavior and then it's no longer tail recursive.

Ray