[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The Web, Continuations, and All That

From: Andy Wingo
Subject: Re: The Web, Continuations, and All That
Date: Tue, 31 Jan 2012 11:00:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Hi Tobias,

On Mon 30 Jan 2012 20:17, Tobias Gerdin <address@hidden> writes:

> 2012/1/23 Andy Wingo <address@hidden>:
>> 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).


    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

(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))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]