X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fmacroexpand.lisp;h=ca38c6c5ae1ebc64b57b0045f43c9e8be9a2cb2c;hb=23c0c48f562d7dc5d1615bf13cb831b46c91d106;hp=36ab43c21604b748ec3c2d3c233706e892a63dec;hpb=68612b8227bdd1a9e70962201f54231c82affa17;p=sbcl.git diff --git a/src/code/macroexpand.lisp b/src/code/macroexpand.lisp index 36ab43c..ca38c6c 100644 --- a/src/code/macroexpand.lisp +++ b/src/code/macroexpand.lisp @@ -35,35 +35,37 @@ fact, a macro. ENV is the lexical environment to expand in, which defaults to the null environment." (cond ((and (consp form) (symbolp (car form))) - (let ((def (sb!xc:macro-function (car form) env))) - (if def - (values (funcall sb!xc:*macroexpand-hook* - def - form - ;; As far as I can tell, it's not clear from - ;; the ANSI spec whether a MACRO-FUNCTION - ;; function needs to be prepared to handle - ;; NIL as a lexical environment. CMU CL - ;; passed NIL through to the MACRO-FUNCTION - ;; function, but I prefer SBCL "be conservative - ;; in what it sends and liberal in what it - ;; accepts" by doing the defaulting itself. - ;; -- WHN 19991128 - (coerce-to-lexenv env)) - t) - (values form nil)))) - ((symbolp form) - (let* ((venv (when env (sb!c::lexenv-vars env))) - (local-def (cdr (assoc form venv)))) - (cond ((and (consp local-def) - (eq (car local-def) 'macro)) - (values (cdr local-def) t)) - ((eq (info :variable :kind form) :macro) - (values (info :variable :macro-expansion form) t)) - (t - (values form nil))))) - (t - (values form nil)))) + (let ((def (sb!xc:macro-function (car form) env))) + (if def + (values (funcall sb!xc:*macroexpand-hook* + def + form + ;; As far as I can tell, it's not clear from + ;; the ANSI spec whether a MACRO-FUNCTION + ;; function needs to be prepared to handle + ;; NIL as a lexical environment. CMU CL + ;; passed NIL through to the MACRO-FUNCTION + ;; function, but I prefer SBCL "be conservative + ;; in what it sends and liberal in what it + ;; accepts" by doing the defaulting itself. + ;; -- WHN 19991128 + (coerce-to-lexenv env)) + t) + (values form nil)))) + ((symbolp form) + (let* ((venv (when env (sb!c::lexenv-vars env))) + (local-def (cdr (assoc form venv)))) + (cond ((and (consp local-def) + (eq (car local-def) 'macro)) + (values (cdr local-def) t)) + (local-def + (values form nil)) + ((eq (info :variable :kind form) :macro) + (values (info :variable :macro-expansion form) t)) + (t + (values form nil))))) + (t + (values form nil)))) (defun sb!xc:macroexpand (form &optional env) #!+sb-doc @@ -72,9 +74,9 @@ lexical environment to expand in, or NIL (the default) for the null environment." (labels ((frob (form expanded) - (multiple-value-bind (new-form newly-expanded-p) - (sb!xc:macroexpand-1 form env) - (if newly-expanded-p - (frob new-form t) - (values new-form expanded))))) + (multiple-value-bind (new-form newly-expanded-p) + (sb!xc:macroexpand-1 form env) + (if newly-expanded-p + (frob new-form t) + (values new-form expanded))))) (frob form nil)))