1.0.44.35: Use DX-FLET instead of FLET in WITHOUT-{INTERRUPTS,GCING}.
[sbcl.git] / src / code / defmacro.lisp
index 0f43bd6..033cc58 100644 (file)
             ;; should deal with clearing old compiler information for
             ;; the functional value."
             ,@(unless set-p
-                '((declare (ignore lambda-list debug-name))))
-            (ecase (info :function :kind name)
-              ((nil))
-              (:function
-               ;; (remhash name *free-funs*)
-               (undefine-fun-name name)
-               (style-warn
-                "~S is being redefined as a macro when it was ~
-                 previously ~(~A~) to be a function."
-                name
-                (info :function :where-from name)))
-              (:macro)
-              (:special-form
-               (error "The special form ~S can't be redefined as a macro."
-                      name)))
-            (clear-info :function :where-from name)
-            ;; FIXME: It would be nice to warn about DEFMACRO of an
-            ;; already-defined macro, but that's slightly hard to do
-            ;; because in common usage DEFMACRO is defined at compile
-            ;; time and then redefined at load time. We'd need to make a
-            ;; distinction between the defined-at-compile-time state and
-            ;; the defined-at-load-time state to make this work. (Trying
-            ;; to warn about duplicate DEFTYPEs runs into the same
-            ;; problem.)
-            #+nil (when (sb!xc:macro-function name)
-                    ;; Someday we could check for macro arguments
-                    ;; being incompatibly redefined. Doing this right
-                    ;; will involve finding the old macro lambda-list
-                    ;; and comparing it with the new one.
-                    (style-warn "redefining ~S in DEFMACRO" name))
-            (setf (sb!xc:macro-function name) definition)
-            #-sb-xc-host
-            (when doc
-              (setf (%fun-doc definition) doc))
-            ,(when set-p
-                   `(setf (%fun-lambda-list definition) lambda-list
-                          (%fun-name definition) debug-name))
+                '((declare (ignore lambda-list debug-name doc))))
+            (let ((kind (info :function :kind name)))
+              ;; Check for special form before package locks.
+              (when (eq :special-form kind)
+                (error "The special operator ~S can't be redefined as a macro."
+                       name))
+              (with-single-package-locked-error (:symbol name "defining ~S as a macro")
+                (when (eq :function kind)
+                  (style-warn
+                   "~S is being redefined as a macro when it was ~
+                     previously ~(~A~) to be a function."
+                   name (info :function :where-from name))
+                  (undefine-fun-name name))
+                (clear-info :function :where-from name)
+
+               ;; FIXME: It would be nice to warn about DEFMACRO of an
+               ;; already-defined macro, but that's slightly hard to do
+               ;; because in common usage DEFMACRO is defined at compile
+               ;; time and then redefined at load time. We'd need to make a
+               ;; distinction between the defined-at-compile-time state and
+               ;; the defined-at-load-time state to make this work. (Trying
+               ;; to warn about duplicate DEFTYPEs runs into the same
+               ;; problem.)
+               #+nil
+               (when (sb!xc:macro-function name)
+                 ;; Someday we could check for macro arguments
+                 ;; being incompatibly redefined. Doing this right
+                 ;; will involve finding the old macro lambda-list
+                 ;; and comparing it with the new one.
+                 (style-warn "redefining ~/sb-impl::print-symbol-with-prefix/ ~
+                                 in DEFMACRO" name))
+               (setf (sb!xc:macro-function name) definition)
+               ,(when set-p
+                      `(setf (%fun-doc definition) doc
+                             (%fun-lambda-list definition) lambda-list
+                             (%fun-name definition) debug-name))))
             name))))
   (progn
     (def (:load-toplevel :execute) #-sb-xc-host t #+sb-xc-host nil)