[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tail Recursion
Date: Wed, 22 Feb 89 11:49 EST
From: barmar@Think.COM (Barry Margolin)
You COULD have the instruction shift
the arguments back into the current stack frame, but that makes
optimized tail calls expensive.
I don't know that it's so bad. Don't arguments get copied pretty
frequently on the 3600 anyway? Like for funcalling of an instance, to
make room for SELF and the mapping table? And multiple values have to
get copied similarly -- multiple times, perhaps, when returned through
several frames.
RMS once implemented tail recursion just this way on the CADR, so I
believe the basic idea is sound. Unfortunately, I don't have any
timings to show the effect on performance in that case. Of course,
there could be some 3600 or Ivory architectural feature that makes it
not work.
The other reason is that eliminating tail calls makes debugging harder,
because frames will not show up in backtraces.
You mean, of course, *some* frames will not show up. It's the same
kind of problem as the fact that once a value has been returned from a
function, it may be hard to recreate the arguments to that function or
even to know which function the value came from. So it's a problem
we're already used to dealing with to some extent. Yes, it gets a
little worse, but it hardly makes debugging impossible.
-- Scott