On Mon, Aug 07, 2000 at 11:44:58PM +0200, Bart Lateur wrote:
> On Mon, 7 Aug 2000 08:31:24 -0400, John Tobey wrote:
> 
> >A continuation is
> >(abstractly) a copy of the stack.  It's the reverse of eval (or, in C,
> >setjmp) in that it lets you back out of a stack frame and later come
> >back to continue it, possibly many times.
> 
> What's the difference with coroutines?

Continuations are more general.  It is possible (though not
recommendable) to implement coroutines, exceptions, and even things
like C<return> using continuations.

Have you ever programmed CGI?  Then you know how horrendously the
request/response paradigm breaks what would be an application's
natural flow.  You'd like to say:

    show_page;
    do {
        get_submission;
        validate_data;
    } while error;
    show_next_page;

but of course you can't, because without continuations, you have to
exit everything to send a page to the browser and rebuild it all when
another request comes in.

But the above code would be possible if get_submission stored the
current continuation in a database before returning to the web server
loop.  The page handler could associate the next request with the
continuation and simply jump back into it when the form was submitted.

-John

Reply via email to