[Seaside] continuations resources
ramon.leon at allresnet.com
Tue Oct 10 18:24:18 UTC 2006
> Thank you for your answers Ramón.
> I would still like to have a pointer to some good resources
> on the subject to read about.
> Thanks again.
I don't really have any pointers handy, you might try searching this list.
A simple way to think of continuations, is something like an exception, but
more general. Exceptions can be implemented via a continuation. When you
fire an exception, you're essentially saying, here, pass this exception
object to the current continuation, i.e. the nearest exception handler.
Continuations are more general however, and are capable of being called many
times. It's like going back in time, somewhere earlier in the code, you
were in a context where you said... Hmm, I want to be able to come back here
and start over, so save this context as the current continuation. Later,
you find yourself in a situation where you want to bail out and start over
again at that spot, so you invoke the current continuation and do exactly
that, time travel back to that point, and continue from wherever it was,
even if that spot was in the middle of a method somewhere. The continuation
starts right at the point in the stack where it left off. Think of it as
calling a no arg method that was created on the fly at any point of your
choosing, even mid execution, at any time in the past.
This is useful in the web context, because you save the continuation, then
render a page to the user, then pack up all the data, put it somewhere, and
restart the continuation right where you left off, as if the render was
instantaneous, allowing the workflow code to be all in one subroutine,
instead of spread out between many pages.
This is my understanding anyway, I could be wrong on some subtle point.
Your best bet, is to read up on Scheme, there's bound to be lots of
documentation on continuations in Scheme, where they're the most popular.
More information about the Seaside