;;;; A program that keeps its own temp arena as an Allocator value and stops. ;;;; test_dev.ml destroys that arena from an expression at the stop, makes a ;;;; new arena — which takes the destroyed one's record — and a Vec in it, then ;;;; resumes. The expression's scratch temp arena must not put the destroyed ;;;; record back as context/temp, or the next frame boundary would wipe the new ;;;; arena as the temp one and the Vec made there would trap. (import agent "vendor:agent") (defstruct Missing [id i32]) (defonce ar Allocator) (defonce tv Allocator) (defonce av (Vec u8)) (defn fetch [] i32 (restart-case (do (error (Missing {.id 1})) 0) (retry [] 7))) (defn hold [] i32 (set tv context/temp) (let [r (fetch)] (println (str (i64->bytes 31))) r)) (defn main [] i32 (agent/start) (println (hold)) ;; A frame boundary, which in a dev build wipes context/temp — the new ;; arena, had the destroyed record been put back as it. (agent/poll) (println (length av)) (println (at av 0)) (dotimes [i 4000] (agent/wait 5)) 0)