Thu Feb 4 07:32:18 UTC 2010 pix@kepibu.org * Merge all MATCH* macros into a single, unified expansion function And, because it's now trivial, add MATCH-COND, MATCHF-COND, MATCH-ECASE, and MATCHF-ECASE. Still to do: Merge documentation of functions so there's less copy-pasta in the documentation strings. diff -rN -u old-cl-unification/match-block.lisp new-cl-unification/match-block.lisp --- old-cl-unification/match-block.lisp 2013-12-22 19:10:57.000000000 +0000 +++ new-cl-unification/match-block.lisp 2013-12-22 19:10:57.000000000 +0000 @@ -10,25 +10,118 @@ (intern (subseq (symbol-name v) 1) (symbol-package v))) -(defun %template-for-match (template) - (if (variablep template) - `',template ; Logical variables are special-cased. - template)) - -(defun %wrap-var-bindings (template environment-var forms) - (let* ((template-vars (collect-template-vars template)) - (bindings (loop for v in template-vars - nconc (list `(,v (find-variable-value ',v - ,environment-var)) - `(,(clean-unify-var-name v) ,v))))) - `(let* ,bindings - (declare (ignorable ,@(mapcar #'first bindings))) - ,@forms))) +(defun %match-expander (template-munger clause-munger clauses + &key default named environment errorp error-form keyform) + "A rather hairy internal function which handles expansion for all the MATCH* macros. + +template-munger should be either 'match or 'matchf, and will massage the +template into the proper form for that macro set. + +clause-munger should be either 'cond, 'case, or 'nil. This affects the expected +syntax of items in clauses as follows: + 'cond: { ((