flan/web/examples/conds.flan
Joseph Ferano dfd64d89ea The examples are files that run, not prose, so the page cannot drift from them
Copying a snippet into HTML is where a documented language stops being the
real one. Each block on the page is a program here with its recorded output
beside it, and check.sh is what says the page is still true after a change.
2026-09-12 03:40:03 +07:00

17 lines
505 B
Plaintext

(defstruct AssetMissing [id i32])
(defvar seen i64)
(defn load-all []
(signal (AssetMissing {:id 1})) ; Unit — the caller carries on
(signal (AssetMissing {:id 2})))
(defn main []
(load-all) ; no handler: a no-op
(print-i64 seen) (newline) ; 0
;; A handler that returns normally accumulates and lets the signaller run on.
(handler-bind [(AssetMissing [c] (set seen (+ seen (i64 (.id c)))))]
(load-all))
(print-i64 seen) (newline)) ; 3