Subject: Re: Lisp or Scheme?
From: (Rob Warnock)
Date: Sun, 27 Aug 2006 06:17:21 -0500
Newsgroups: comp.lang.lisp,comp.lang.scheme
Message-ID: <>
Anton van Straaten  <> wrote:
| Rob Warnock wrote:
| > But how do you provide *multiple* continuations using CALL/CC syntax?
| To illustrate using your form example, you can define a macro along 
| these lines: (define-syntax form-let ...[elided]... )
| You can use it like this:
| (form-let ((form1 make-form1 handle-form1)
|             (form2 make-form2 handle-form2))
|    (send/suspend (make-page form1 form2)))

Neat! By hoisting the building of the forms into the FORM-LET,
you get to generate multiple continuations. Now why didn't *I*
think of that...?  ;-}  ;-}

[Answer: Because I use an s-expr-based HTML-generator (HTOUT,
but it could be CL-WHO or HTMLGEN or others), I tend to generate
the forms sequentially inline, and thus was thinking that there
was only one possible continuation to SEND-SUSPEND.]

| When either of the two forms is submitted by the client, the 
| corresponding continuation is invoked.  This restarts execution at the 
| point at which either form1 or form2 was bound, setting them to the 
| result of the form submission.  The form? test detects that it has been 
| given something other than a form (i.e. it has a result), and the 
| corresponding handler is invoked.  Once the handler completes, execution 
| would continue "after" the form-let expression, i.e. the form-let 
| expression's continuation is invoked with the result returned by the 
| form handler.

I suspect another reason I didn't think of this approach is that,
using it, the usual default continuation created by SEND/SUSPEND is
*abandoned* completely, since that continuation is never invoked.

| I set up this example for ease of illustration, but it's easy enough to 
| make a more integrated version to support e.g. constructing a page with 
| multiple forms as a single inline sexp, without requiring procedures 
| such as make-form.

Sure. Just initialize a collection at the start of the page generation,
and as each form is generated push its continuation onto the collection,
[But as above, the default continuation created by SEND/SUSPEND is
abandoned if any of the forms is submitted.]

Thanks for the tip. Some of the ideas apply even if one *isn't*
using "real" continuations on the server...


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607