X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fmacroexpand.lisp;h=cb60c38d9dcdeb7d36cbec6b5674edf3da6f63ee;hb=cd1b14acf6f548b28b8a14e554d779f0473122ec;hp=4b7a1a2d686e813a93f181b57f728fb5398c4432;hpb=260f59fdcebbbfe56f65406ab77fcb6cbc760c45;p=sbcl.git diff --git a/src/code/macroexpand.lisp b/src/code/macroexpand.lisp index 4b7a1a2..cb60c38 100644 --- a/src/code/macroexpand.lisp +++ b/src/code/macroexpand.lisp @@ -88,3 +88,21 @@ (frob new-form t) (values new-form expanded))))) (frob form nil))) + +;;; Like MACROEXPAND-1, but takes care not to expand special forms. +(defun %macroexpand-1 (form &optional env) + (if (or (atom form) + (let ((op (car form))) + (not (and (symbolp op) (sb!xc:special-operator-p op))))) + (sb!xc:macroexpand-1 form env) + (values form nil))) + +;;; Like MACROEXPAND, but takes care not to expand special forms. +(defun %macroexpand (form &optional env) + (labels ((frob (form expanded) + (multiple-value-bind (new-form newly-expanded-p) + (%macroexpand-1 form env) + (if newly-expanded-p + (frob new-form t) + (values new-form expanded))))) + (frob form nil)))