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.
24 lines
818 B
Plaintext
24 lines
818 B
Plaintext
(defconst rows 3)
|
|
(defconst cols 4)
|
|
|
|
;; A fixed array is a value: inline storage, copies on assignment.
|
|
(defconst palette [4 u32] [0xE6B800FF 0x3B6E8CFF 0xA83232FF 0xCC6B1FFF])
|
|
|
|
;; No initialiser means all-bytes-zero, so this is BSS and costs nothing.
|
|
(defonce grid [rows [cols i32]])
|
|
|
|
(defn main [] ()
|
|
(set (at grid 1 2) 7)
|
|
(print (at grid 1 2)) (println "") ; 7
|
|
(print (len palette)) (println "") ; 4
|
|
|
|
;; A slice is ptr+len and non-owning: it views the array, it does not copy it.
|
|
(let [row (slice (at grid 1) 0 cols)]
|
|
(set (at row 0) 5)
|
|
(print (at grid 1 0)) (println "") ; 5 — the same storage
|
|
(print (sum-i32 row)) (println "")) ; 12
|
|
|
|
;; (zeroed) is a memset, not an allocation.
|
|
(set grid (zeroed))
|
|
(print (at grid 1 2)) (println "")) ; 0
|