[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: linear continuations



On Sat, 20 Apr 2002, James Knight wrote:

> I hadn't (until Avi's message) realized that anyone implemented
> multi-shot continuations with copied bindings, instead of the Scheme way
> of using the same stack frames multiple times with all the weirdness
> that implies. The Smalltalk semantics make a lot more sense, and I'd be
> much happier with an implementation that worked like that (if just for
> the reason that imperative and recursive loops are equivalent).

Note that these aren't standard Smalltalk semantics for continuations - I
don't know of any Smalltalk that comes with call/cc "out of the box".
However, it was the most natural and most useful way for me to implement
them (the usefulness is obvious, the naturalness stems from the typical
representation of a stack frame in Smalltalk-80 and its descendants, which
has the program counter, method pointer and bindings all in one
contiguous, easy to copy chunk of memory).  In VisualWorks, call/cc can be
implemented in this way in about 10 lines of code (!).  Squeak takes a few
more to work around the lack of proper block closures.

> However, having it copy a piece of the program when a continuation is
> used multiple times makes me wonder even more whether "the right
> thing" would be to copy the whole program. [leaving aside the
> efficiency issue for the moment, that is].

Well, not for my purposes.  The useful thing is having good control over
what does get copied and what doesn't.  Generally this breaks down to the
view/controller side being copied and the model side having side effects,
although obviously those distinctions aren't always so clean.

I suppose you could use fork and make that boundary an IPC one, if you
weren't concerned about efficiency.  That might be an interesting thing to
experiment with.

Cheers,
Avi