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.
29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
;;;; The zero-argument (agent/start): a program that names no socket at all.
|
|
;;;;
|
|
;;;; Under [flan dev] it binds where the daemon said, exactly as the explicit
|
|
;;;; form did, and nothing here can tell the difference. Run on its own — which
|
|
;;;; is what test_agent.ml does with it — it picks a path under /tmp and prints
|
|
;;;; it to stderr, and that printed line is the only way anything could connect.
|
|
;;;;
|
|
;;;; The second start is here to be a no-op. It answers 0 like the first, does
|
|
;;;; not bind a second socket, and does not print a second line; a program that
|
|
;;;; got its listener from somewhere else and also asks for one by hand is the
|
|
;;;; case that has to keep working.
|
|
(import agent "vendor:agent")
|
|
|
|
(defonce ticks i64)
|
|
|
|
(defn tick [] i64
|
|
(set ticks (+ ticks 1))
|
|
ticks)
|
|
|
|
(defn main [] i32
|
|
(if (< (agent/start) 0)
|
|
(do (println "cannot listen") 1)
|
|
(do
|
|
(print (agent/start)) (println "")
|
|
(print (tick)) (println "")
|
|
(while (= (agent/wait 100) 0) 0)
|
|
(print (tick)) (println "")
|
|
0)))
|