Subject: Re: Lisp or Scheme?
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 25 Aug 2006 08:45:34 -0500
Newsgroups: comp.lang.lisp,comp.lang.scheme
Message-ID: <zo2dnafKr7tjY3PZnZ2dnUVZ_rqdnZ2d@speakeasy.net>
Ken Tilton  <kentilton@gmail.com> wrote:
+---------------
| Face it, a continuation is just a cute trick for managing state, such 
| that one need not think about it because it is all on the stack. I 
| concede the trick -- hey, no need to think out what state to preserve, 
| but then the counterpoint is, well, when I accidentally did my faux 
| continuations i did not have to think out the state because the 
| requisite data structures were already in place for other reasons.
+---------------

And this is also exactly why "real" [in the Scheme sense] continuations
are not what you need [or maybe even want!] in web programming, either.

Yes, in the *very simplest* cases using "real" continuations lets you
blindly ignore what state you want to save [with all the potential
problems that implies!], but in practice with complex sites you have
so much other state you have to manage explicitly anyway [including such
things as aging (timeouts) and GC-ing SQL connections, "sessions", etc.]
that using "real" continuations just gets in the way, e.g.:

    http://www.ccs.neu.edu/scheme/pubs/ase2001-gfkf.pdf
    ...
    Several months of actual experience using the server for an
    outreach project's Web sites [ref] revealed that problems with
    timeouts matter in practice.

As you say, in practice "the requisite data structures [are usually]
already in place for other reasons", so emulating the user-visible
*behavior* of continuations [which is what I'm understanding your
"faux continuations" are doing] is all you really need to do. Plus,
if you want to store *lots* of continuations, then you need to be
able to externalize them [in a database or something], in which case
your "faux continuations" (what some people call "manually CPS'd" code)
are much easier to handle.

Don't get me wrong: I still think the "web continuations" *model*
is a great way to think about the user/server interactions -- it
"does the right thing" when a user has multiple browser windows
open to the same site [unlike cookies, which lose big in that case!]
and when the user likes the "Back" and "Open in New Window/Tab" buttons.
I want to thank Queinnec, Felleisen, Krishnamurthy, and various others
who have written so eloquently on the subject. But just because "web
continuations" are a good model for *designing* the navigation and
interactions doesn't mean that "real" continuations are actually the
right way to *implement* the site. These days, I happend to think
they aren't. But then, I code my sites in Common Lisp, so I *have*
to think that way, right?  ;-}

But seriously, folks, there's usually a *lot* of DBMS & "business
logic" & HTML-generating code between desired continuation points,
so manually CPS-transforming your code [and then tagging each procedure
with an externalizable marker] isn't a great strain, at least, not
in my experience.


-Rob

p.s. As I posted here a couple of weeks ago, I do use a
BUILD-CONTINUATION function all over the place in HTML
form-generating code, that simply sets one or more hidden
form variables (one of them almost always named "state"!).
See <URL:news:j4GdnazAuoV9MEfZnZ2dnUVZ_t2dnZ2d@speakeasy.net>
for a small code example.

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607