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.
42 lines
1.7 KiB
Plaintext
42 lines
1.7 KiB
Plaintext
;;;; A data type imported from a package, which was a refusal until vendor/edn
|
|
;;;; needed one — "an imported data type is not implemented yet (milestone 4)".
|
|
;;;;
|
|
;;;; Four things, and each is a different way the rename could be half done:
|
|
;;;; the type named in a signature, a constructor written on this side of the
|
|
;;;; import, a constructor the *package* wrote and the import had to rewrite,
|
|
;;;; and a match whose patterns name the cases bare. The last is the one that
|
|
;;;; needs no rename at all — a pattern resolves against the scrutinee's type —
|
|
;;;; and it is here so that the day someone qualifies case names too, this says
|
|
;;;; what broke.
|
|
|
|
(import tree "pkgs/tree")
|
|
|
|
(defonce frame Allocator)
|
|
|
|
;; The type in a signature, and a bare pattern over a value the package made.
|
|
(defn describe [t tree/Node] string
|
|
(match t
|
|
(Leaf _n) "leaf"
|
|
(Branch _k) "branch"
|
|
Empty "empty"))
|
|
|
|
(defn main [] i32
|
|
(set frame (arena-new 4096))
|
|
(with-allocator frame
|
|
(let [kids (vec-new tree/Node)]
|
|
;; Written here, qualified, which is how the importer spells it.
|
|
(push kids (tree/Node.Leaf {.n (i64 1)}))
|
|
;; Written inside the package, unqualified, and rewritten by the import.
|
|
(push kids (tree/leaf (i64 2)))
|
|
(push kids (tree/nothing))
|
|
(let [t (tree/Node.Branch {.kids kids})]
|
|
(println (describe t))
|
|
(println (describe (tree/leaf (i64 9))))
|
|
(println (describe (tree/nothing)))
|
|
;; Summed by the package's own match, over a value this file built, so
|
|
;; the two sides agree about the layout and not only about the names.
|
|
(println (tree/total t)))))
|
|
(free-all frame)
|
|
(arena-destroy frame)
|
|
0)
|