[Cuis] Solitaire updated for 2203

Ken.Dickey Ken.Dickey at whidbey.com
Sun Apr 5 09:07:50 CDT 2015


On Sat, 4 Apr 2015 22:15:09 -0700
Casey Ransberger <casey.obrien.r at gmail.com> wrote:

> Just jumping in here late Juan, but...
> 
> In a Smalltalk environment, continuations may be somewhat expensive because the way we pull it off is keeping our closures on the heap. 

Continuations are expensive as currently implemented in Cuis.  THey can be nade much cheaper, but it takes work to do so.

They are also like GOTOs in that they are in general too powerful. One can think of making a copy of the stack when a continuation is captured.  In most cases, you really only reuse a bit of stack at the end, hence interest in "delimited continuations", "one-shot continuations" and so forth.

In the current context, it is much cheaper to use closures.  It seems simpler to me as well. 

> Don't quote me on this, and I can't immediately cite any sources (sorry) but I recall reading that systems that can do tail-call elimination can cut down on the cost significantly.

Tail call elimination is important to reduce stack usage.  If the last thing one does in a method is 'call' another method, we say the call is in the 'tail' position.  In such cases, you don't need to push another stack frame, you can adjust (if required) and reuse the current stack frame.  Pushing a new stack frame is doing too much work and grows the stack unnecessarily.

Where a different number of arguments are passed, one may have to adjust the stack frame size.

If you do 'tail call elimination' you are eliminating the extra push of a stack frame and can express all control flow as message sends.  One thinks of a tail call as a goto which pases arguments.

With closures, one has to do 'escape analysis' to see what 'captured variables' are actually shared and allocate them on the heap rather than in the stack.  This is because closures or continuations may be invoked multiple times and any shares state must be 'seen' the same by all.

-- 
-KenD




More information about the Cuis mailing list