From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Emsley Newsgroups: gmane.lisp.guile.user Subject: Re: Long-lived Guile scripts in a mono-threaded game engine Date: Tue, 27 May 2008 14:42:26 +0100 Message-ID: <483C0FC2.60102@bioch.ox.ac.uk> References: <20080526211900.GB14261@perso.beuc.net> <87fxs4yy89.fsf@gnu.org> <20080527083324.GA16693@perso.beuc.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1211895788 4407 80.91.229.12 (27 May 2008 13:43:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 May 2008 13:43:08 +0000 (UTC) To: guile-user@gnu.org, beuc@beuc.net Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue May 27 15:43:48 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K0zSV-0004MH-9m for guile-user@m.gmane.org; Tue, 27 May 2008 15:43:23 +0200 Original-Received: from localhost ([127.0.0.1]:42629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K0zRk-0007sy-5U for guile-user@m.gmane.org; Tue, 27 May 2008 09:42:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K0zRf-0007qB-J0 for guile-user@gnu.org; Tue, 27 May 2008 09:42:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K0zRe-0007nR-47 for guile-user@gnu.org; Tue, 27 May 2008 09:42:31 -0400 Original-Received: from [199.232.76.173] (port=42110 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K0zRd-0007n8-PR for guile-user@gnu.org; Tue, 27 May 2008 09:42:29 -0400 Original-Received: from relay4.mail.ox.ac.uk ([129.67.1.163]:43979) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K0zRd-0004I2-HP for guile-user@gnu.org; Tue, 27 May 2008 09:42:29 -0400 Original-Received: from smtp1.mail.ox.ac.uk ([129.67.1.207]) by relay4.mail.ox.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1K0zRb-0002AY-DU; Tue, 27 May 2008 14:42:27 +0100 Original-Received: from impala.biop.ox.ac.uk ([163.1.16.107]) by smtp1.mail.ox.ac.uk with esmtp (Exim 4.68) (envelope-from ) id 1K0zRa-00071K-6R; Tue, 27 May 2008 14:42:27 +0100 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) In-Reply-To: <20080527083324.GA16693@perso.beuc.net> X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6579 Archived-At: Sylvain Beucler wrote: > Hi, > > On Tue, May 27, 2008 at 09:58:46AM +0200, Ludovic Courtès wrote: > >>> Scripts last more than a single game loop. They are not basic scripts >>> that describe what happens in a single engine step; instead they >>> describe what happens in the story. >>> >>> For example, a game introduction will create sprites on the screen, >>> move them around, make them say lines that the user can read (or pass >>> using [space]), etc. >>> >>> That script can also change the current screen (which kills all other >>> scripts in the current script). >>> >>> Multiple scripts can run in a single screen, but they run the one >>> after the other, not in parallel. The order/priority is known. >>> >>> Scripting is essentially frozen during the screen refresh. This avoids >>> putting mutexes everywhere. >>> >>> >>> >>> >>> How could I do something similar with Guile? I didn't find a way to >>> make a guile script pause (and return to the caller). >>> >> IIUC, "scripts" are only invoked via hooks, e.g., the engine wants to >> ask them to do something specific. If that is the case, it suffices to >> not invoke the script. >> >> Surely you can implement coroutine-like behavior, either using `call/cc' >> (but that is going to be prohibitively expensive), or using explicit >> continuation-passing style or similar. For instance, when a hook is >> called by the engine, it would systematically return a thunk (a >> zero-argument procedure) that the engine would later invoke. Example: >> >> (define (my-hook action) >> (let ((stuff (do-some-computation action))) >> (lambda () >> ;; This will be executed at some later point, when the engine >> ;; feels like invoking it. >> (do-the-remaining-computation stuff)))) >> >> Does this help? >> > > Ok, so what I'm looking for isn't supported natively :/ > > > Here's a sample script (very close to the C bindings, for a start): > > [snip script] > > Now every time we see a (say_stop), the script will pause for 2 > seconds, so the player can read the text. > what is the nature of the pause? (I think that that might be important.) How do you interrupt the tight little say_stop sleep loop (if that's what it is) when you are using C bindings? > Maybe I'm missing a more simple solution? > > Maybe.