Next: API Reference, Previous: Command Line Interface, Up: Top [Contents][Index]
One of the biggest appeals of any Lisp dialect is the ability to use the “read-eval-print loop” (REPL for short) to build programs iteratively and interactively while the program is running. However, programs that run in an event loop and respond to user input (such as a game using the Chickadee library!) require special care for this workflow to be pleasant.
If you are using the chickadee play
command to run your
game, then the --repl
or --repl-server
arguments are all
you need to get a live coding environment running.
If, however, you are using run-game
to start the game loop then
it’s still fairly easy to hook up a special kind of REPL by yourself.
First, create a cooperative REPL server (It’s important to use Guile’s
cooperative REPL server instead of the standard REPL server in
(system repl server)
to avoid thread synchronization issues).
Then, in the game loop’s update procedure, call
poll-coop-repl-server
and pass the REPL object. Here is a
template to follow:
(use-modules (chickadee) (system repl coop-server)) (define repl (spawn-coop-repl-server)) (define (update dt) (poll-coop-repl-server repl) ...) (run-game #:update update ...)
To use the REPL, connect to it via port 37146. Telnet will do the
trick, but using the Geiser
extension for Emacs is by far the best way to develop at the REPL with
Guile. Use M-x connect-to-guile
to connect to the REPL server.