flan/test/programs/reload.flan
Joseph Ferano 57fe91f303 Five records become one, and every citation lands somewhere
FIX.org, NEXT.md, DISCUSS.org, docs/DISCUSS.md and the session handoff at the
root are one TODO.org now: 293 entries under seven subsystem headings, each
carrying an org keyword that says where it stands. A DONE entry is a few lines
saying what was decided and what that rules out; the reasoning that would not
compress — the embedding spike and the four reports the hand-written x86
backend was built from — moved into docs/BUILT.md instead, and its entries
point there in one line.

Every entry was checked against the tree before it got a keyword, and the
prose was wrong in both directions. Things the deleted files called open were
built: the first-evaluation stall, main being redefinable, macro parameter
lists, the type-limit constants, the array constructors, the byte fills,
inc/dec, the discard's fontification, the Emacs buffers, rt_die's _exit, the
backtrace surface, and the acceptance failure that could print and still exit
zero. Things they called done were not: the backend reports' no-plan buckets
had gone stale in the other direction, the value-dependent defvar was
superseded rather than built, and macro-expansion source locations are on an
unmerged lane, so that entry is NEXT and names the branch.

Every comment that cited one of the five by name now cites a heading that
exists, in TODO.org or in docs/BUILT.md. The session reports under
docs/handoffs/ keep naming the files they worked on, because rewriting them
would falsify what those sessions did; each carries a note saying where the
content went.
2026-09-21 21:05:48 +07:00

56 lines
2.7 KiB
Plaintext

;;;; The reload primitive's fixture, v1 (TODO.org, "The dev loop, step 1: the reload primitive").
;;;;
;;;; There is deliberately no [main]: the host is reload_host.c, which links
;;;; this program and then dlopens two rebuilt copies of [bump].
;;;;
;;;; [counter] is the state that has to survive a reload — a redefinition
;;;; module declares it [external], so the loaded object writes the host's copy
;;;; and not a new one. [outer] is the call site that has to *follow* a reload:
;;;; it is compiled once, into the host, and never rebuilt, so if a redefined
;;;; [bump] runs when the host calls [outer] then the cell is doing its job.
;;;; The string is not decoration either — a redefinition module has to carry
;;;; its own constants, and a one-function module usually has none.
(defonce counter i64)
;;; A move-only global, which is allowed because reading one is always a borrow
;;; (spec-memory.md, "Globals of move-only type"). It is here for the reload
;;; question rather than the ownership one: a redefinition module declares it
;;; [external] like any other host global, so a load must not hand the module
;;; its own zeroed header -- that would drop the storage the running process is
;;; still using, which is the failure a plain i64 counter cannot exhibit
;;; because a re-zeroed i64 merely looks wrong.
(defonce tally (Vec u8))
;;; Unused, and that is the point: the session's compatibility rules only get a
;;; chance to speak about a change the *checker* accepts, and retyping a var
;;; something else reads is an ordinary type error long before it is a layout
;;; question.
(defonce spare i64)
;;; Unused too, and here for the redefinition-module question a [def] adds:
;;; its initialiser is lifted into [global/paint] whatever it is — a literal
;;; included — so re-evaluating the form republishes that function through
;;; its cell, and [global/paint] is a *non-sibling* target (its parent is the
;;; global, not a function in the form). test_reload greps the module's IR
;;; for the cell declaration that publish needs.
(def paint i64 7)
;;; Also unused, and for the same reason: a defconst's value and an enum
;;; member are folded into every call site, so a session has to refuse changing
;;; either. Nothing here reads them, so the checker has no opinion and the
;;; session's rule is the only thing that can speak.
(defconst folded i64 7)
;;; ...and one that is not: an array constant is never an array length, so its
;;; value is only ever read at run time and a dev build can store a new one.
(defconst palette [2 u32] [1 2])
(defenum Colour [red 0 green 1])
(defn helper [x i64] i64 (* x 2))
(defn bump [] i64
(println "v1")
(set counter (+ counter 1))
(helper counter))
(defn outer [] i64 (bump))