guile-user
[Top][All Lists]
Advanced

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

Re: Interactive programming with Event Loop?


From: Christopher Howard
Subject: Re: Interactive programming with Event Loop?
Date: Fri, 06 Oct 2017 07:53:54 -0800

Thanks, I implemented what you described a few days ago and it has been
working well for me. Just two notes for posterity:

- I recommend starting the app inside a separate (non-emacs) terminal,
and then connecting to that from inside emacs with geiser. If you let
lots of stdout/stderr get dumped to an emacs buffer, it slows your
computer down to a crawl.
- As you mentioned to me personally, one has to use trampolines for
hooks to make this programming approach work.

On Fri, 2017-10-06 at 09:01 -0400, Thompson, David wrote:
> Hello Christopher,
> 
> On Sat, Sep 30, 2017 at 1:23 AM, Christopher Howard
> <address@hidden> wrote:
> > Hi, I want to code a game using theChickadee framework, but I want
> > to
> > do it in an interactive programming environment, where I can
> > evaluate
> > things in the REPL while the Chickadee kernel is running, rather
> > than
> > needing to restart the kernel after each modification. The
> > Chickadee
> > kernel runs update hooks every so many milliseconds, so I think I
> > just
> > need to figure out a way to communicate code to an update hook,
> > that it
> > could execute. What would be the simplest and/or most sensible way
> > to
> > do this? (Threads? IPC? Communicate to a network port?)
> 
> Mark is right that a cooperative REPL server is the answer here.  We
> both worked on that feature a few years ago for exactly this purpose.
> 
> Here is a simple example program that has a REPL server added in:
> 
>     (use-modules (chickadee)
>                  (chickadee math vector)
>                  (chickadee render sprite)
>                  (chickadee render texture)
>                  (system repl coop-server))
> 
>     (define sprite #f)
>     (define repl #f)
> 
>     (define (load)
>       (set! sprite (load-image "images/chickadee.png"))
>       (set! repl (spawn-coop-repl-server)))
> 
>     (define (draw alpha)
>       (draw-sprite sprite (vec2 256.0 176.0)))
> 
>     (define (update dt)
>       (poll-coop-repl-server repl))
> 
>     (add-hook! load-hook load)
>     (add-hook! update-hook update)
>     (add-hook! draw-hook draw)
>     (add-hook! quit-hook abort-game)
> 
>     (run-game)
> 
> Once the program is running, you can connect to the REPL server over
> a
> tcp socket on port 37146.  If you use Geiser, which I highly
> recommend, just run `M-x connect-to-guile` and use the default
> connection settings.
> 
> Hope this helps,
> 
> - Dave
> 
-- 
Christopher Howard
Enterprise Solutions Manager
Alaska Satellite Internet
3239 La Ree Way
Fairbanks, Alaska 99709
1-888-396-5623
https://alaskasatelliteinternet.com
personal web site: https://qlfiles.net
https://emailselfdefense.fsf.org/en/


Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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