Package: alexandria
Macro destructuring-case
Lambda Listdestructuring-case (keyform &body clauses) SyntaxDetails The macro destructuring-case is a combination of the Common Lisp
macros case
and destructuring-bind. keyform must evaluate to a cons. The clause whose case-keys matches car of key, as if by the Common Lisp macro case is selected, and the forms are then executed with the cdr of key is destructured and bound by the destructuring-lambda-list. Examples(defun dcase (x) (destructuring-case x ((:foo a b) (format nil "foo: ~S, ~S" a b)) ((:bar &key a b) (format nil "bar, ~S, ~S" a b)) (((:alt1 :alt2) a) (format nil "alt: ~S" a)) ((t &rest rest) (format nil "unknown: ~S" rest)))) | See also |