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.
31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
;;;; v3 introduces names the host was never built with: a defonce [extra] and a
|
|
;;;; defn [added]. There is no symbol in the running process to bind either to
|
|
;;;; and ELF cannot grow one, so both are keyed by string through
|
|
;;;; runtime/flan_dev.c and resolved once when the module is installed.
|
|
;;;;
|
|
;;;; [bump] is redefined in the same module, which is the point of the unit
|
|
;;;; being a list of forms rather than one function: C-c C-k on a file that
|
|
;;;; adds a var and uses it has to work in one load, or the intermediate state
|
|
;;;; is a module referring to storage that does not exist yet.
|
|
(defonce counter i64)
|
|
(defonce extra i64)
|
|
;;; And a run-time-new one of move-only type: no symbol to bind to, so it goes
|
|
;;; through the by-name registry like [extra], with its declared initial value
|
|
;;; travelling along as a constant. A zeroed Vec is an empty Vec, so that
|
|
;;; constant is a zeroinitializer and the allocation the registry makes is a
|
|
;;; usable Vec rather than a placeholder.
|
|
(defonce fresh (Vec u8))
|
|
|
|
(defn helper [x i64] i64 (* x 2))
|
|
|
|
(defn added [] i64
|
|
(set extra (+ extra 7))
|
|
extra)
|
|
|
|
(defn bump [] i64
|
|
(println "v3")
|
|
(set counter (+ counter (added)))
|
|
(helper counter))
|
|
|
|
(defn outer [] i64 (bump))
|