flan/test/programs/dev-repl.flan
Joseph Ferano a4c6b996ff def re-runs its initialiser, and defvar is renamed defonce
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.
2026-09-21 07:12:04 +07:00

34 lines
1.5 KiB
Plaintext

;;;; A program that just runs, for evaluating expressions against.
;;;;
;;;; Unlike dev-loop.flan it does not count reloads and stop: C-x C-e is a
;;;; thunk the agent runs at a frame boundary, so a program under test has to
;;;; keep reaching them. (agent/wait 5) is both the poll and the pacing — 5ms
;;;; of nothing, which is what a frame is when there is no frame.
(import agent "vendor:agent")
;;; A condition, so that a body typed in later can error and stop the program
;;; where an editor can see it. It is here rather than in the evaluated form
;;; because the break loop matches on a class the *host* was compiled with.
(defstruct Missing [id i32])
(defonce ticks i64)
(defn step [] i64
(set ticks (+ ticks 1))
ticks)
(defn main [] i32
(agent/start "/tmp/flan-dev-repl-fallback.sock")
;; 24000 and not the 4000 the other fixtures use, because this one is the
;; whole of test_emacs: one daemon carries every check from `flan-connect' to
;; the break loop, and 4000 ticks of 5ms is a two-minute test with a
;; twenty-second program in it. Run the suite on a machine with several
;; compilers on it and the program can reach its last tick while the client
;; is still working — which fails honestly ("the program exited; restart flan
;; dev") but fails for a reason that has nothing to do with what was being
;; checked. dev-robust.flan is 24000 for the same reason and got there first.
;; The watchdogs, at 600s, are what actually bounds the run.
(dotimes [i 24000]
(agent/wait 5)
(set ticks (step)))
0)