maxima-bounces at math.utexas.edu wrote on 11/16/2006 09:38:35 AM:
> On Thu, 2006-11-16 at 06:58 -0600, Barton Willis wrote:
> . . .
> > Compiling a Maxima function does remove tail-recursion. (Maybe CL
> > isn't required to do this, but GCL does.) Removing tail-recursion
> > allows a recursively defined function to handle larger data:
>
> By "removing tail-recursion" you mean transforming tail-recursion into
> iteration?
Oh, dear. I wrong and unclear.
> > (%i1) sumlist(l) := if l = [] then 0 else first(l) + sumlist(rest(l))$
> > (%i2) p : makelist((-1)^k,k,1,1000)$
> > (%i3) sumlist(p);
> > Error in PROGN [or a callee]: Bind stack overflow.
>
> But, this function isn't tail-recursive, that is, the recursive call to
> sumlist is not what is known as a tail call, since further work (the
> addition) is done on the result returned by the recursive call.
I stand corrected. I don't know why GCL gives the Lisp error in (%i3)
and not after compiling.
Thanks for the correction.
Barton