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.
25 lines
822 B
Plaintext
25 lines
822 B
Plaintext
;;;; v4 redefines only [added] — itself introduced at run time by v3, so it
|
|
;;;; lives in the registry and not in any symbol table.
|
|
;;;;
|
|
;;;; This is the case that separates a real implementation from a plausible
|
|
;;;; one. v3's [bump] is already installed and is not rebuilt here, so it picks
|
|
;;;; this up only if its call to [added] goes through a *cell* that both
|
|
;;;; modules found by name. Had v3 cached the address of the function instead
|
|
;;;; of the address of its cell, everything else would still pass and this
|
|
;;;; would silently keep running v3's [added].
|
|
(defonce counter i64)
|
|
(defonce extra i64)
|
|
|
|
(defn helper [x i64] i64 (* x 2))
|
|
|
|
(defn added [] i64
|
|
(set extra (+ extra 100))
|
|
extra)
|
|
|
|
(defn bump [] i64
|
|
(println "v3")
|
|
(set counter (+ counter (added)))
|
|
(helper counter))
|
|
|
|
(defn outer [] i64 (bump))
|