37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
;;;; A program that stops while it holds things in the temp allocator: [hold]'s
|
|
;;;; formatted text in a live frame, and [keep], a Vec made from context/temp.
|
|
;;;; [fetch] errors with nothing handling it, so the program stops there.
|
|
;;;; Expressions evaluated at the stop format numbers of their own and push
|
|
;;;; into [keep], which grows it through the program's temp arena, possibly
|
|
;;;; into a new chunk. After the retry restart the program prints the text and
|
|
;;;; [keep]'s length, first and last element; all of it has to be intact.
|
|
;;;; test_dev.ml drives it.
|
|
(import agent "vendor:agent")
|
|
|
|
(defstruct Missing [id i32])
|
|
|
|
(defonce keep (Vec u8))
|
|
|
|
(defn fetch [] i32
|
|
(restart-case
|
|
(do (error (Missing {.id 1})) 0)
|
|
(retry [] 7)))
|
|
|
|
(defn hold [] i32
|
|
(set keep (vec-new u8 context/temp))
|
|
(push keep (u8 5))
|
|
(let [s (str (i64->bytes 4242))
|
|
r (fetch)]
|
|
(println s)
|
|
(println (length keep))
|
|
(println (at keep 0))
|
|
(println (at keep (- (length keep) 1)))
|
|
r))
|
|
|
|
(defn main [] i32
|
|
(agent/start)
|
|
(println (hold))
|
|
(dotimes [i 4000]
|
|
(agent/wait 5))
|
|
0)
|