flan/test/programs/dev-pause.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

37 lines
1.3 KiB
Plaintext

;;;; A program to set a breakpoint in, for driving `C-u C-c C-c' from an editor.
;;;;
;;;; Unlike dev-break.flan it does not stop on its own: it starts running and
;;;; keeps running, because the claim being tested is that marking a form is
;;;; what stops it. Anything already stopped would prove nothing.
;;;;
;;;; What it needs is a function that keeps being called, so that a mark set
;;;; after startup is hit, and hit again after the mark is cleared. dev-loop.flan
;;;; calls [step] four times, which is too tight for that; this is dev-break.flan's
;;;; tail with nothing in front of it.
(import agent "vendor:agent")
(defonce ticks i64)
;;; Something to stop on that is *not* a breakpoint, so that a marked
;;; expression sent to an already-stopped program can be told from the break it
;;; was already sitting in. It is here rather than in an evaluated form for the
;;; reason dev-loop.flan gives: the break loop matches on a class the host was
;;; compiled with.
(defstruct Missing [id i32])
(defn boom [] i64
(restart-case
(do (error (Missing {.id 1})) 0)
(carry-on [] -1)))
(defn step [] i64
(set ticks (+ ticks 1))
ticks)
(defn main [] i32
(agent/start "/tmp/flan-dev-pause-fallback.sock")
(dotimes [i 4000]
(agent/wait 5)
(set ticks (step)))
0)