flan/test/programs/dev-repl.flan
Joseph Ferano 8a94f16acd The program's output goes where someone is looking at it
Its stdout is a pipe into the daemon now, and whatever it printed since the
last reply rides along with the next one into *flan-output*. Arriving with a
reply rather than by a separate request is the point: the output an evaluation
itself caused is the output anyone wants to see.

Draining that pipe is a liveness requirement, not a nicety. A pipe nobody reads
fills at 64K and the next write blocks the program forever, so it is read from
the accept loop's select whether or not an editor is asking, and the buffer is
capped - a program printing every frame must not grow the daemon without limit,
and the newest text is the useful end.

test_dev read the program's transcript off the daemon's stdout, which is no
longer where it goes; it collects :output from replies instead, which is also
what the editor does. The emacs test moved to a fixture that keeps running,
since it now evaluates more times than the old one had reloads to give.
2026-09-11 07:05:50 +07:00

22 lines
638 B
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")
(defvar ticks i64)
(defconst step-by i64 3)
(defn step [] i64
(set ticks (+ ticks 1))
ticks)
(defn main [] i32
(agent/start "/tmp/flan-dev-repl-fallback.sock")
(dotimes [i 4000]
(agent/wait 5)
(set ticks (step)))
0)