flan/web/examples/defer.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

12 lines
279 B
Plaintext

(defn work [n i32] i32
(defer (print-line "second"))
(defer (print-line "first")) ; innermost-first at exit
(when (< n 0)
(return 0)) ; runs both defers above it
(print-line "body")
n)
(defn main []
(print-i64 (i64 (work 3)))
(newline))