(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-i64 (i64 (fetch 1))) (newline) ; 101 — nothing handled it (handler-bind [(AssetMissing [c] (invoke-restart 'use-placeholder))] (print-i64 (i64 (fetch 2))) (newline)) ; -1 (print-i64 cleanups) (newline)) ; 2 — the defer ran both times