;;;; A program that stops with state worth looking at *outside* the frame. ;;;; ;;;; dev-locals.flan is about what one frame holds. This is about what the ;;;; whole stopped stack is reading, which in this language is most of the ;;;; program: a game keeps its state in top-level defvars, and sand.flan holds ;;;; its entire grid that way. ;;;; ;;;; The globals are declared in an order the answer must *not* come back in. ;;;; [label] is written first and is touched only by [main], the outer frame, ;;;; so ordering by the innermost frame that touches it has to put it last; ;;;; [grid] and [pressure] are both innermost-touched and must keep the order ;;;; they are declared in. [untouched] is read by no frame on the stack and ;;;; must not appear at all — that is the whole claim of scoping the section to ;;;; the stack rather than listing everything the program has. (import agent "vendor:agent") (defstruct Boom [why i32]) (defvar label string) (defvar grid [4 i32]) (defvar pressure i64) (defvar untouched i64 99) ;; The inner frame. It writes two globals and then errors with nothing ;; handling the condition, so the program stops here with [main] under it. (defn inner [] i64 (set pressure 12) (set (at grid 0) 7) (error (Boom {.why 3})) 0) (defn main [] i32 (agent/start "/tmp/flan-dev-globals-fallback.sock") (set label "running") (set (at grid 1) 5) (print (inner)) (println "") (dotimes [i 4000] (agent/wait 5)) 0)