;;;; The reload primitive's fixture, v1 (NEXT.md, dev loop step 1 and 2). ;;;; ;;;; 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. (defvar counter i64) ;;; 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. (defvar spare i64) (defn helper [x i64] i64 (* x 2)) (defn bump [] i64 (print-line "v1") (set counter (+ counter 1)) (helper counter)) (defn outer [] i64 (bump))