(defstruct AssetMissing [id i32]) (defvar cleanups i64) (defn load [n i32] i32 (signal (AssetMissing {.id n})) 100) (defn middle [n i32] i32 (defer (set cleanups (+ cleanups 1))) ; runs on the transfer too (+ (load n) 1)) (defn fetch [n i32] i32 (restart-case (middle n) ; its value if nothing transfers (use-placeholder [] -1) (retry [] 7))) (defn main [] (print (fetch 1)) (println "") ; 101 — nothing handled it (handler-bind [(AssetMissing [c] (invoke-restart 'use-placeholder))] (print (fetch 2)) (println "")) ; -1 (print cleanups) (println "")) ; 2 — the defer ran both times