unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Tobias Gerdin <tgerdin@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: Guile Users <guile-user@gnu.org>
Subject: Re: The Web, Continuations, and All That
Date: Mon, 6 Feb 2012 20:49:38 +0100	[thread overview]
Message-ID: <CAJiKzQMvptM3fK=bdUfVf5wV5Ne7Crz4t-cLBjuoVvY+p16msA@mail.gmail.com> (raw)
In-Reply-To: <87vcnsur79.fsf@pobox.com>

2012/1/31 Andy Wingo <wingo@pobox.com>:
> 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 :)

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	other threads:[~2012-02-06 19:49 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
2012-02-06 19:49         ` Tobias Gerdin [this message]
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='CAJiKzQMvptM3fK=bdUfVf5wV5Ne7Crz4t-cLBjuoVvY+p16msA@mail.gmail.com' \
    --to=tgerdin@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=wingo@pobox.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).