guile-user
[Top][All Lists]
Advanced

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

Re: The Web, Continuations, and All That


From: Tobias Gerdin
Subject: Re: The Web, Continuations, and All That
Date: Mon, 6 Feb 2012 20:49:38 +0100

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

So if a Scheme primitive the program calls happens to be implemented
in C you would run into this problem? As you saw my examples were
quite minimal and maybe not representative of what you do "in
practice". But I agree that given this implementing more things in
Scheme definitely makes sense.

>> [...]
>
> 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))))))

Great, all set then!

-Tobias



reply via email to

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