Jeff~

On Wed, 10 Nov 2004 10:40:45 -0800, Jeff Clites <[EMAIL PROTECTED]> wrote:
> I was thinking: Implementing tail calls seems easy; the normal calling
> sequence of "do some setup, then jump" just turns into "don't bother
> with (most of) the setup, just jump". That is, don't move a new
> register base-pointer into place, etc.

I find thinking in terms of continuations directly make this a little
easier to envision.  consider the following code

sub bar() {
  return foo();
}

in the normal case this will be 

sub bar( parentContinuation) {
  myContinuationForCC;
  temp = foo(myContinuationForCC);
CC:
  parentContinuation(temp);
}

in the tailcall case, this will be

sub bar( parentContinuation) {
  foo(parentContinuation);
}

> 
> But there's one wiggle: If you've created a continuation previously
> (and it still exists), then any call has to preserve the frame--you
> basically can't do a tail call, with its key implication of the
> "current frame" vaporizing, or being re-used (depending on how you want
> to describe it).

In the case that your current frame has already had a continuation of
it taken, then the created continuation would already be doing the
work of ensuring that the frame does not evaporate (after all the
created continuation IS the frame).  Thus, you should still be able to
just pass your parent continuation to whatever you are calling without
any reservations.

At least that is how I understand it,
Matt
-- 
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-???

Reply via email to