From: "Neil Jerram" <neiljerram@googlemail.com>
To: "Clinton Ebadi" <clinton@unknownlamer.org>
Cc: guile-user@gnu.org
Subject: Re: Long-lived Guile scripts in a mono-threaded game engine
Date: Tue, 27 May 2008 22:49:01 +0100 [thread overview]
Message-ID: <49dd78620805271449u1778b5c2k56408fdabcdff9ce@mail.gmail.com> (raw)
In-Reply-To: <87fxs3624n.fsf@unknownlamer.org>
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]
2008/5/27 Clinton Ebadi <clinton@unknownlamer.org>:
> You are pretty much doing what call/cc does, and so could
> straightforwardly rewrite the functions that cause scripts to freeze
> to capture the current continuation and schedule an event to resume
> this continuation when needed. So something like:
>
> (define (say-stop message)
> (call/cc (lambda (k)
> (%say-stop message k))))
>
> This might be worth trying and might perform well enough, but Guile's
> call/cc is fairly slow and heavyweight as it must copy the entire C
> stack.
The amount of the stack that needs copying could be reduced, though, by
putting a continuation barrier (scm_c_with_continuation_barrier) in the C
code shortly before it calls out to Guile.
Personally, I'd try the continuation approach. I did something just like
this for a dayjob-related project, where a key objective was to make the
Scheme scripts as friendly-looking as possible to non-Scheme people. I used
continuations to make it possible to write a script as a sequence of
apparently synchronous operations that were really asynchronous (i.e. send a
request somewhere, and wait for an asynchronous response). It can be done
in such a way that the call/cc is hidden down in the infrastructure, and
script-writers never need to see it.
A complication in my case was that the C code was sensitive to unusual
return patterns. So I also needed to use a continuation to protect the C
code; I can provide more detail about that if needed.
Regards,
Neil
[-- Attachment #2: Type: text/html, Size: 1917 bytes --]
next prev parent reply other threads:[~2008-05-27 21:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-26 21:19 Long-lived Guile scripts in a mono-threaded game engine Sylvain Beucler
2008-05-27 7:58 ` Ludovic Courtès
2008-05-27 8:33 ` Sylvain Beucler
2008-05-27 13:20 ` Ludovic Courtès
2008-05-27 16:14 ` Sylvain Beucler
2008-05-27 18:08 ` Ludovic Courtès
2008-05-27 19:57 ` Sylvain Beucler
2008-05-27 20:30 ` Clinton Ebadi
2008-05-27 18:19 ` Clinton Ebadi
2008-05-27 21:49 ` Neil Jerram [this message]
2008-05-27 13:42 ` Paul Emsley
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=49dd78620805271449u1778b5c2k56408fdabcdff9ce@mail.gmail.com \
--to=neiljerram@googlemail.com \
--cc=clinton@unknownlamer.org \
--cc=guile-user@gnu.org \
/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).