Documentation
NB: the clauses wil be compiled at macro expansion time.
Source
(defmacro match-case (form &rest clauses)
"NB: the clauses wil be compiled at macro expansion time."
(when clauses
(destructuring-bind ((spec &rest body) &rest other-clauses) clauses
(with-unique-names (form-sym matched-p dummy bindings)
(multiple-value-bind (matcher-func vars)
(make-matcher spec)
(declare (ignore matcher-func))
`(let ((,form-sym ,form))
(multiple-value-bind (,matched-p ,dummy ,bindings)
(match (make-matcher ',spec) ,form-sym)
(declare (ignore ,dummy) (ignorable ,bindings))
(if ,matched-p
(let ,vars
,@(mapcar (lambda (var-name)
`(setf ,var-name (cdr (assoc ',var-name ,bindings))))
vars)
,@body)
(match-case ,form-sym ,@other-clauses)))))))))
Source Context