From e7d470e954d0a17ab1b2fe0065f46f78475272f9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 8 Apr 2020 17:10:29 -0400 Subject: Add chickade 0.5.0 stuff. --- manuals/chickadee/Live-Coding.html | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 manuals/chickadee/Live-Coding.html (limited to 'manuals/chickadee/Live-Coding.html') diff --git a/manuals/chickadee/Live-Coding.html b/manuals/chickadee/Live-Coding.html new file mode 100644 index 0000000..167c87a --- /dev/null +++ b/manuals/chickadee/Live-Coding.html @@ -0,0 +1,127 @@ + + + + + + +Live Coding (The Chickadee Game Toolkit) + + + + + + + + + + + + + + + + + + + +
+

+Previous: , Up: Kernel   [Contents][Index]

+
+
+

2.1.4 Live Coding

+ +

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 video game) require special care for this workflow to be pleasant. +Chickadee provides no built-in support for live coding, but it’s +fairly easy to hook up a special kind of REPL 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. +

+ + + + + -- cgit v1.2.3