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.
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
;;;; The session's fixture for generics in the dev loop.
|
|
;;;;
|
|
;;;; A generic [defn] never reaches [Tast.fns] — only its copies do — so every
|
|
;;;; question the editor asks about one has to be answered by expanding the
|
|
;;;; name. This file is the smallest program that makes each of those
|
|
;;;; questions concrete: one generic used at two element types, one generic
|
|
;;;; that calls another so that instantiation has to be transitive, and one
|
|
;;;; call site whose element type is *not* used anywhere else, so that a
|
|
;;;; redefinition can reach a copy the process was never built with.
|
|
|
|
(defonce counter i64)
|
|
|
|
(defn put-at [xs [$t] i i32 v $t] ()
|
|
(set (at xs i) v))
|
|
|
|
;;; Calls [put-at] at its own variable, so the copy of [put-at] is generated when
|
|
;;; [hold] is instantiated and not before.
|
|
(defn hold [xs [$t] v $t] ()
|
|
(put-at xs 0 v))
|
|
|
|
(defn pick [xs [$t]] $t
|
|
{:where (ordered? $t)}
|
|
(let [m (at xs 0)]
|
|
(dotimes [i (len xs)]
|
|
(set m (min m (at xs i))))
|
|
m))
|
|
|
|
(defn step [] ()
|
|
(let [ns [5 3 9 1]
|
|
fs [2.5 0.5 1.5]]
|
|
(hold (slice ns 0 4) 7)
|
|
(hold (slice fs 0 3) 0.25)
|
|
(set counter (+ counter (i64 (pick (slice ns 0 4)))))))
|
|
|
|
(defn main [] ()
|
|
(step)
|
|
(println counter))
|