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.
22 lines
776 B
Plaintext
22 lines
776 B
Plaintext
;;;; Value semantics, spec-memory.md. Not covered by calc-me, and the property
|
|
;;;; most likely to be silently wrong in a backend: a struct or a fixed array
|
|
;;;; copies on assignment, a slice copies only its view.
|
|
(defstruct P [x i32])
|
|
(defonce arr [3 i32])
|
|
|
|
(defn main [] i32
|
|
(let [a (P {.x 1})]
|
|
(let [b a] ; a copy, not an alias
|
|
(set (.x a) 99)
|
|
(print (.x b)) (println ""))) ; 1
|
|
|
|
(set (at arr 0) 5)
|
|
(let [c arr] ; fixed arrays are values too
|
|
(set (at arr 0) 77)
|
|
(print (at c 0)) (println "")) ; 5
|
|
|
|
(let [s (bytes-view "hello")]
|
|
(let [v (slice s 1 3)] ; a view into the same bytes
|
|
(print v) (println ""))) ; el
|
|
0)
|