Tail Call

Scott A Crosby crosby at qwes.math.cmu.edu
Fri Feb 1 18:08:07 UTC 2002


On Fri, 1 Feb 2002, Anthony Hannan wrote:

> Scott A Crosby <crosby at qwes.math.cmu.edu> wrote:
> > On Fri, 1 Feb 2002, Anthony Hannan wrote:
> >
> > [ foo foo foo. ^self someMessage]
>
> Tail call implementation for the first case is what I was describing
> above and is messy.  I would just leave the normal call for this case.
>

Excellent!

>
> We could add a method to BlockClosure called #copyStack that will copy
> its home context call stack.  This way everytime you want to use it as a
> continuation that may be used again you call this first.  We can even
> have an #asContinuation method that would wrap the block closure in a
> Continuation object that when invoked would send #copyStack to the block
> closure first.  Note: "closure" continuations are only applicable to
> blocks having explicit returns (capturing their home context).  A block
> closure without an explicit return is just a regular object (holding
> captured temp values) with an extra instance-specific method that is
> invoked via #value...

Two things, first, it *may* make sense to do the stack copy lazily, in
that you only copy the blockclosures if they actually get returned into.
With these continuations, you may frequently save them, but not actually
use them. Maybe.. I don't know. :) You know, not I.


Also, for the interface, how about using the typical call/cc interface?
Have a method, somewhere, called 'callCC"

callCC: aBlock
  aBlock value: [BlockClosure asContinuation]

Which calls the requested block on the continuation into this method? This
would allow basically straightforward ports of any other call/cc code to
squeak.

Scott





More information about the Squeak-dev mailing list