acond improvements

This commit is contained in:
mehbark 2024-12-20 03:37:02 -05:00
parent 1410aa68c8
commit 468cfad8b4

View file

@ -463,12 +463,17 @@
((null (cdr args)) (car args))
(t `(aif ,(car args) (aand ,@(cdr args))))))
; improvements inspired by SBCL https://github.com/sbcl/sbcl/blob/42d939ea06063bcddd29d628a4ba6613edf4bcf8/src/code/primordial-extensions.lisp#L321 (should probably destructure too :P)
(defmacro acond (&rest clauses)
(if (null clauses)
nil
(once-only ((test (caar clauses)))
`(if ,test
(let ((it ,test)) ,@(cdar clauses))
,(aif (cdar clauses)
`(let ((it ,test))
(declare (ignorable it))
,@it)
test)
(acond ,@(cdr clauses))))))
(defmacro alambda (args &body body)