;;;; A class, instances of it, and a session that changes the class. ;;;; ;;;; dev-class.flan already asks whether a *method* added to a running ;;;; program reaches a call site compiled before it existed. This asks the ;;;; harder half: whether the instances already in the program survive their ;;;; class being redefined. They are ordinary dyn maps held in a dyn global, ;;;; so the reload cannot touch them — a redefinition makes a program's ;;;; globals external and never re-initialises them, which is the whole of ;;;; "edit the code, keep the sand" — and what the editor sends is a new ;;;; constructor plus a registration of the class's new slot list. The ;;;; migration happens lazily, in the runtime, at the first touch after that. ;;;; ;;;; [instances] is a global rather than a local for exactly that reason: an ;;;; expression the editor evaluates is a thunk with a frame of its own, so ;;;; anything it is supposed to still be holding an hour later has to live ;;;; somewhere the thunk is not. ;;;; ;;;; The instances are pushed by the editor rather than by [main], and that ;;;; is not incidental. A (defclass ...) whose slots change is a constructor ;;;; whose signature changes, and the session refuses that wherever a ;;;; compiled caller of the constructor is left standing — a call site that ;;;; passes two dyn words into a three-parameter body leaves the third ;;;; holding a register, and a dyn word that is not a value is a wild ;;;; pointer. A [main] calling [(point 3 4)] would be exactly such a caller, ;;;; so this program has none and the instances arrive from thunks, which ;;;; leave nothing behind. test_session.ml pins the refusal itself. ;;;; ;;;; It keeps running rather than returning, for dev-class.flan's reason: an ;;;; expression typed at the editor is a thunk the agent runs at a frame ;;;; boundary, and a parked program has none. (import agent "vendor:agent") (defclass point [x y]) (defgeneric area [self] dyn) (defmethod area point [p] (* (get p :x) (get p :y))) (defonce instances dyn) (defn main [] i32 (agent/start "/tmp/flan-dev-classes-fallback.sock") (set instances (vec-new dyn)) (dotimes [i 4000] (agent/wait 5)) 0)