flan/test/programs/reload-v3.flan
Joseph Ferano 96ab4c9cf0 Retire the per-type printers, since print says all of it
print-str, print-i64, print-f64, print-bytes, print-line and newline leave
the prelude. print and println are the whole printing surface now, and print
is the better call at every one of the sites that used them: it is the same
structural walk without the newline, so the no-newline case the family was
kept for is covered, and it takes the value as it is. The old print-i64
forced an explicit (i64 x) at every call site, because this language widens
nothing implicitly; that cast is gone from 127 places.

Dropping it moves one answer. hash-grid returns u64, and the cast through
the signed printer showed sand-headless's hash as -2851001042534928384.
print routes a u64 through flan_u64_to_bytes, so it now prints
15595743031174623232 — the same 64 bits, read as the unsigned number they
are. The pinned expectation follows the correction.

test-flan-dev.el and test_session.ml both reached for print-line as "a name
the prelude has"; they reach for rand-seed instead.
2026-09-12 05:32:25 +07:00

25 lines
845 B
Plaintext

;;;; v3 introduces names the host was never built with: a defvar [extra] and a
;;;; defn [added]. There is no symbol in the running process to bind either to
;;;; and ELF cannot grow one, so both are keyed by string through
;;;; runtime/flan_dev.c and resolved once when the module is installed.
;;;;
;;;; [bump] is redefined in the same module, which is the point of the unit
;;;; being a list of forms rather than one function: C-c C-k on a file that
;;;; adds a var and uses it has to work in one load, or the intermediate state
;;;; is a module referring to storage that does not exist yet.
(defvar counter i64)
(defvar extra i64)
(defn helper [x i64] i64 (* x 2))
(defn added [] i64
(set extra (+ extra 7))
extra)
(defn bump [] i64
(println "v3")
(set counter (+ counter (added)))
(helper counter))
(defn outer [] i64 (bump))