Austin Hastings wrote:
--- Rod Adams <[EMAIL PROTECTED]> wrote:
A guess from my current understanding:
You're wanting to play with a database. You take a continuation. You
see if have a database handle open and good to go, if so you do your
thing. (can you then dismiss the continuation? do uninvoked continuations
pile up somewhere?). If the handle is not ready, you do everything needed
to prepare the handle, and then invoke the continuation.
But I don't see how a continuation gained you much over
C<prepare($dbh) unless ready($dbh);>.
So what makes them so cool?
You know how you can log in to your webmail/slashdot/sourceforge/amazon account, and get a cookie that says you're logged in?
And you know how you can then go into your browser's history list and pick up some entry that was invalid, or came from yesterday, and when you click through, the cookie (local data) that says you're legitimately logged in stays with you, so the site doesn't give you a hard time?
That's continuation-like behavior.
Continuations will let you take "function pointers" at an arbitrary location: instead of entering the top of the function, you can come in to the middle. They are similar to setjmp/longjmp in this context: you have to pass through once to "take" the continuation, before you can invoke it. But you can invoke it arbitrarily many times, unlike set-/long-jmp, since the continuation closes over the entire call stack.
=Austin
Well, that's another explanation that jives with my understanding of them..... But I still don't have an idea of when I would actually want to use them in something I'm writing.
-- Rod