X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fmacroexpand.lisp;h=36ab43c21604b748ec3c2d3c233706e892a63dec;hb=bfe145acc01eb7a43790173db4f08610ae9cb07a;hp=4806e01d6f010b8947747cc7639f72a8158ab810;hpb=cea4896b2482b7b2b429c1631d774b4cfbc0efba;p=sbcl.git diff --git a/src/code/macroexpand.lisp b/src/code/macroexpand.lisp index 4806e01..36ab43c 100644 --- a/src/code/macroexpand.lisp +++ b/src/code/macroexpand.lisp @@ -15,7 +15,7 @@ (defun sb!xc:special-operator-p (symbol) #!+sb-doc - "If the symbol globally names a special form, returns T, otherwise NIL." + "If the symbol globally names a special form, return T, otherwise NIL." (declare (symbol symbol)) (eq (info :function :kind symbol) :special-form)) @@ -28,12 +28,11 @@ whenever a runtime expansion is needed. Initially this is set to FUNCALL.") -(declaim (ftype (function (t &optional (or null sb!c::lexenv))) sb!xc:macroexpand-1)) (defun sb!xc:macroexpand-1 (form &optional env) #!+sb-doc - "If form is a macro (or symbol macro), expands it once. Returns two values, + "If form is a macro (or symbol macro), expand it once. Return two values, the expanded form and a T-or-NIL flag indicating whether the form was, in - fact, a macro. Env is the lexical environment to expand in, which defaults + 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))) @@ -50,20 +49,22 @@ ;; in what it sends and liberal in what it ;; accepts" by doing the defaulting itself. ;; -- WHN 19991128 - (or env (make-null-lexenv))) + (coerce-to-lexenv env)) t) (values form nil)))) ((symbolp form) - (let* ((venv (when env (sb!c::lexenv-variables env))) + (let* ((venv (when env (sb!c::lexenv-vars env))) (local-def (cdr (assoc form venv)))) - (if (and (consp local-def) - (eq (car local-def) 'macro)) - (values (cdr local-def) t) - (values form nil)))) + (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)))) -(declaim (ftype (function (t &optional (or null sb!c::lexenv))) sb!xc:macroexpand)) (defun sb!xc:macroexpand (form &optional env) #!+sb-doc "Repetitively call MACROEXPAND-1 until the form can no longer be expanded.