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.
47 lines
1.2 KiB
Plaintext
47 lines
1.2 KiB
Plaintext
;; The rest of the core: a global with an initialiser, recursion, break and
|
|
;; continue, the bitwise family, unsigned arithmetic and shifts, and the
|
|
;; conversions in both directions.
|
|
|
|
(defonce counter i64 0)
|
|
|
|
(defconst limit i32 6)
|
|
|
|
(defn fib [n i64] i64
|
|
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
|
|
|
|
(defn main [] i32
|
|
(print (fib 20)) (println "")
|
|
|
|
(let [i 0]
|
|
(while (< i 100)
|
|
(set i (+ i 1))
|
|
(when (= i 7) (break)))
|
|
(print i) (println ""))
|
|
|
|
(let [j 0 seen 0]
|
|
(while (< j 10)
|
|
(set j (+ j 1))
|
|
(when (= (% j 2) 0) (continue))
|
|
(set seen (+ seen j)))
|
|
(print seen) (println ""))
|
|
|
|
(dotimes [k limit]
|
|
(set counter (+ counter (i64 k))))
|
|
(print counter) (println "")
|
|
|
|
(let [a (bit-xor (u32 0x0F0F0F0F) (u32 0xFFFFFFF))
|
|
b (u32 0x0F0F0F0F)]
|
|
(print (bit-or a b)) (println "")
|
|
(print (bit-and a b)) (println "")
|
|
(print (bit-xor a (u32 65535))) (println "")
|
|
(print (>> a 4)) (println "")
|
|
(print (<< b 4)) (println ""))
|
|
|
|
(let [x (i32 -9)]
|
|
(print (/ x 2)) (println "")
|
|
(print (% x 2)) (println "")
|
|
(print (f64 x)) (println "")
|
|
(print (i32 (f64 3.9))) (println "")
|
|
(print (f32 1.5)) (println ""))
|
|
0)
|