cl: unwind-protect — cleanup frame in cl-eval-ast, 8 new tests (159 eval)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 11:13:53 +00:00
parent a12a6a11cb
commit fd16776dd2
2 changed files with 38 additions and 0 deletions

View File

@@ -309,6 +309,16 @@
(:else (run (+ i 1))))))))))
(run 0))))
;; ── UNWIND-PROTECT ───────────────────────────────────────────────
(define cl-eval-unwind-protect
(fn (args env)
(let ((protected (nth args 0))
(cleanup (rest args)))
(let ((result (cl-eval protected env)))
(for-each (fn (f) (cl-eval f env)) cleanup)
result))))
;; ── BLOCK / RETURN-FROM ───────────────────────────────────────────
(define cl-eval-block
@@ -605,6 +615,7 @@
((= head "TAGBODY") (cl-eval-tagbody args env))
((= head "GO")
{:cl-type "go-tag" :tag (nth args 0)})
((= head "UNWIND-PROTECT") (cl-eval-unwind-protect args env))
((= head "BLOCK") (cl-eval-block args env))
((= head "RETURN-FROM") (cl-eval-return-from args env))
((= head "RETURN")