Tail Call
Jesse Welton
jwelton at pacific.mps.ohio-state.edu
Fri Feb 1 21:10:22 UTC 2002
Scott A Crosby wrote:
>
> 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.
Call/cc is a way of applying the argument function to the current
continuation. As such, it seems (as with #value:) that #callCC would
be a method sent to the block.
BlockClosure>>callCC
^self value: thisContext continuation
Example usage:
retryCount := [:cont | retry := [cont value: retryCount+1]. 0] callCC.
-Jesse
More information about the Squeak-dev
mailing list
|