The trio the author decided on 2026-09-20 is now all built: def is CL's defparameter — its initialiser runs on every daemon re-run, unguarded, so an edited initialiser repaints the same storage on C-c C-c plus re-run — defonce (Clojure's name for CL's defvar, per the author) initialises once behind the .init~once. flag, and defconst stays the image. One parse arm reads both forms; the difference is Ast.reinit, carried to Tast.global's grerun. Emit.startup_plan gives a def no guard flag, and Check.check_global lifts every def initialiser — zero and literal included — into global/<n>, so the host's startup reaches it through the function cell and a re-evaluated def swaps it (Session's def_inits; Emit.redefinition declares the cell for a non-sibling target). The old defvar spelling is refused with the rename and both compiling spellings, and every program, test, doc and editor list is swept — except sand.flan, the author's live WIP, whose seven defvar lines are flagged in FIX.org and keep its three dependent tests red on this branch.
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
;;;; The agent, end to end: a running program takes a redefinition over a
|
|
;;;; socket and installs it between "frames".
|
|
;;;;
|
|
;;;; [tick] is the function that gets redefined. It is called once before any
|
|
;;;; reload and once after each of two of them, and nothing else in this file
|
|
;;;; changes, so the three numbers are the whole result. Two reloads and not
|
|
;;;; one because that is the daemon's actual loop: a second module built from
|
|
;;;; the same session, reading state the first one introduced.
|
|
;;;;
|
|
;;;; It waits rather than polling on a timer because a test that races the
|
|
;;;; frame rate is a test that fails on a loaded machine. A game loop calls
|
|
;;;; poll at the top of the frame and ignores the answer; the split is in
|
|
;;;; vendor/agent/agent.flan.
|
|
(import agent "vendor:agent")
|
|
|
|
(defonce ticks i64)
|
|
|
|
(defn tick [] i64
|
|
(set ticks (+ ticks 1))
|
|
ticks)
|
|
|
|
(defn main [args [string]] i32
|
|
(if (< (len args) 2)
|
|
(do (println "usage: agent <socket>") 2)
|
|
(do
|
|
(if (< (agent/start (at args 1)) 0)
|
|
(do (println "cannot listen") 1)
|
|
(do
|
|
(print (tick)) (println "")
|
|
(while (= (agent/wait 100) 0) 0)
|
|
(print (tick)) (println "")
|
|
(while (= (agent/wait 100) 0) 0)
|
|
(print (tick)) (println "")
|
|
0)))))
|