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

Re: linear continuations



On Friday, April 19, 2002, at 03:20  PM, Allen Short wrote:
>> Single-shot continuations have a lot going for them, but unless I'm
>> missing something, being able to be stack-allocated is not one of them.
>
> Linear continuations are different from single-shot continuations:
> single-shot continuations are still capturable and can be referenced
> multiple times; I have been told that multi-shot continuations can be
> built from single-shot ones (but still cannot track down the paper in
> which this is demonstrated). However, linear continuations have no
> implicit continuation -- that is, the function called by call/lc cannot
> return, it must call the continuation passed to it at some point.
> Thus, you dont have the time-travel effects that prevent
> stack-allocation of continuations.

This still confuses me. As far as I can tell, in my example, the 
continuations are linear. In 'yield', the continuation is either used 
immediately, or stuck in a list to be used later. In no case does more 
than one thing have a reference to it at once. When it is later pulled 
off the list, it is immediately consumed, and noone else can have a 
reference to it. Control flow can never (at least I don't think it can) 
fall off the end of the function provided to call/cc. What's the 
essential bit of knowledge I'm missing?

>> it makes me think that what you really want to have for 
>> web-applications
>> is fork().
>
> Exactly. in a linear-continuations system, you'd have to explicitly copy
> the current continuation to get a new thread.

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). 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].

James