[LRUG] Continuations
benjohn at fysh.org
benjohn at fysh.org
Thu Mar 15 07:22:06 PDT 2007
Thanks for your reply!
> If you use exceptions, you have to keep track of which alternatives
> you've tried, and they don't get thrown to the right place, if that
> makes sense. Continuations help enormously because they help
> encapsulate the bookkeeping (they're also useful for handling
> backtracking of your state)
Okay, I think I can buy that pretty easily.
*snip*
>> I've also heard of continuation based web servers. Perhaps these could
>> be a good way of explaining continuations too?
>
> The trouble with using a continuation based webserver (say) as your
> point of entry to explaining how continuations work is that, if you
> get the implementation right, you never actually see the continuations
> when you're writing your webapp; you just see (probably) a new control
> structure (actually, what you tend to see is a *lack* of a control
> structure because the continuations take care of it in the background
> and you don't have to write all that explicit control logic).
I see what you're saying, but I think that could work though. You would
explain how the library user sits there happily writing what seems like
a vanila imperative application. Having set the scene, you can then
reveal how on earth a library is able to provide that abstraction -
internally it's using continuations to pause interaction a given user's
session, and even allow them to use the back button to backtrack to
earlier points and procede forwards from them instead...
> The thinking behind the blog post was based on the idea that
> continuations are, in a sense, the ur-control structure; once you have
> continuations you can use them to implement pretty much all the
> control structures you need, which is why I gave examples of using
> continuations to replace return, break, next and redo. It's not that
> it's a sensible thing to do with them (after all, we already *have*
> return, break, next and redo so why reinvent), just that they are
> things that people already (I hope) understand.
:-) I'm going to re-read it now and see if it clicks for me this time.
Thanks!
Cheers,
Benj
More information about the Chat
mailing list