From 468cfad8b4e1f7b5a227df9b28eb26fb8baff2ee Mon Sep 17 00:00:00 2001 From: mehbark Date: Fri, 20 Dec 2024 03:37:02 -0500 Subject: [PATCH] acond improvements --- utils.lisp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.lisp b/utils.lisp index 4f756fa..f686448 100644 --- a/utils.lisp +++ b/utils.lisp @@ -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)