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.
28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
;;;; The reload primitive's fixture, v2. Three differences from v1, each one a
|
|
;;;; separate thing being checked:
|
|
;;;;
|
|
;;;; [bump] steps by 10 and adds 1000, so the host's untouched call site in
|
|
;;;; [outer] visibly runs the new body rather than the one it was linked to.
|
|
;;;;
|
|
;;;; [bump] also calls *itself*. Inside a shared object a plain call would be
|
|
;;;; interposed by the host's copy — the module would look self-consistent and
|
|
;;;; silently run the old body — so the self-call goes through the cell like
|
|
;;;; any other. If it did not, the first recursive step would print "v1" and
|
|
;;;; the transcript would say so.
|
|
;;;;
|
|
;;;; [helper] is changed only as a tripwire. The module declares it rather than
|
|
;;;; defining it, so this body is dead text and the call has to land on the
|
|
;;;; host's [* x 2]; with the two bodies identical nothing at run time would
|
|
;;;; notice a module that grew its own copy.
|
|
(defonce counter i64)
|
|
(defonce tally (Vec u8))
|
|
|
|
(defn helper [x i64] i64 (* x 3))
|
|
|
|
(defn bump [] i64
|
|
(println "v2")
|
|
(set counter (+ counter 10))
|
|
(if (> counter 100) (+ (helper counter) 1000) (bump)))
|
|
|
|
(defn outer [] i64 (bump))
|