unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Tobias Gerdin <tgerdin@gmail.com>
Cc: Guile Users <guile-user@gnu.org>
Subject: Re: The Web, Continuations, and All That
Date: Tue, 31 Jan 2012 11:00:42 +0100	[thread overview]
Message-ID: <87vcnsur79.fsf@pobox.com> (raw)
In-Reply-To: <CAJiKzQPBjLyWnRsAbAf58BVzjvhxB0ni3wHv62MJJYaOccNv0g@mail.gmail.com> (Tobias Gerdin's message of "Mon, 30 Jan 2012 20:17:05 +0100")

Hi Tobias,

On Mon 30 Jan 2012 20:17, Tobias Gerdin <tgerdin@gmail.com> writes:

> 2012/1/23 Andy Wingo <wingo@pobox.com>:
>> Did you ever run into problems with non-resumable continuations?
>
> At times I was scratching my head and wondering what was going on but
> if you mean continuations that wouldn't resume due to a bug I do not
> think so.

If a partial continuation includes a trip through C and then back to the
VM, it won't be resumable.  Basically if you call a function that is
implemented in C and then that function does a scm_call(...), and you
abort from within the scm_call(...), the abort works but the
continuation will not be resumable.

This is an implementation restriction.  We're trying to get around it by
having more things implemented in Scheme rather than C.

The reason for this restriction is that you can't capture part of the C
stack, then compose it with some other C continuation (i.e., splat it at
some other stack position).

E.g.:

    scheme@(guile-user)> (call-with-prompt 'foo (lambda () (call-with-output-string (lambda args (abort-to-prompt 'foo)))) (lambda (k) k))
    $1 = #<partial-continuation 2b63200>
    scheme@(guile-user)> ($1)
    ERROR: In procedure #<partial-continuation 2b63200>:
    ERROR: Throw to key `vm-error' with args `(vm-run "Unrewindable partial continuation" (#<vm-continuation 2b73aa0>))'.

    Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
    scheme@(guile-user) [1]> 

I asked you this because I was wondering I wanted to know how we were
doing in practice: if you happened to run into this.  So it's nice that
you didn't run into it :)

> What I think would be nice would be to add a (web server control)
> library making the most common web programming continuation operators
> available for use in any framework built on top of (web server). This
> would probably require installing a prompt in `run-server' somewhere,
> (but that is not too expensive I think in the case it's never used?)
> and having some policy on how the continuation table is to be managed.
> One simple way would be to make use of a weak hashtable, although that
> may not be ideal in all situations.

There is a prompt in the server.  The handler is applied to the request,
body, and state values in a thunk, and that thunk is called in one of
these:

(define (with-stack-and-prompt thunk)
  (call-with-prompt (default-prompt-tag)
                    (lambda () (start-stack #t (thunk)))
                    (lambda (k proc)
                      (with-stack-and-prompt (lambda () (proc k))))))

Andy
-- 
http://wingolog.org/



  reply	other threads:[~2012-01-31 10:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-22 18:46 The Web, Continuations, and All That Tobias Gerdin
2012-01-22 20:46 ` Ian Price
2012-01-23 21:11   ` Andy Wingo
2012-01-30 19:17     ` Tobias Gerdin
2012-01-31 10:00       ` Andy Wingo [this message]
2012-02-06 19:49         ` Tobias Gerdin
2012-02-07  8:48           ` Andy Wingo
2012-01-25  8:59   ` Antono Vasiljev
     [not found]   ` <4F1FC437.8020801@antono.info>
2012-01-25 10:32     ` Ian Price
2012-01-30 19:03       ` Tobias Gerdin
2012-01-31  9:06         ` Ian Price
2012-02-04  9:53           ` Ian Price
     [not found]           ` <CAJiKzQMETO7g6YyqCbeoV0GD09gena6RK6q6bYhjTOe+wNq+Uw@mail.gmail.com>
2012-02-06 19:40             ` Fwd: " Tobias Gerdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vcnsur79.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-user@gnu.org \
    --cc=tgerdin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).