Raymond Toy pushed to branch issue-499-defmacro-restart-for-locked-packages at cmucl / cmucl Commits: 7fb7b8d9 by Raymond Toy at 2026-05-01T15:04:42-07:00 Move all of the restart stuff from defmacro to %%defmacro Only moved part of the code from defmacro. We really want all of it. - - - - - 1 changed file: - src/code/macros.lisp Changes: ===================================== src/code/macros.lisp ===================================== @@ -77,11 +77,11 @@ ;;; definition is done by %defmacro which we expand into. ;;; (defmacro defmacro (name lambda-list &body body) + #+nil (when lisp::*enable-package-locked-errors* (multiple-value-bind (valid block-name) (ext:valid-function-name-p name) (declare (ignore valid)) - #+nil (let ((package (symbol-package block-name))) (when package (when (ext:package-definition-lock package) @@ -138,28 +138,33 @@ (c::%%defmacro name definition doc)) ;;; (defun c::%%defmacro (name definition doc) - (let ((package (symbol-package name))) - (when package - (when (and (ext:package-definition-lock package) - ;; Bootstrap. This might not be bound yet. - (boundp 'lisp::*enable-package-locked-errors) - lisp::*enable-package-locked-errors) - (restart-case - (error 'lisp::package-locked-error - :package package - :format-control (intl:gettext "defining macro ~A") - :format-arguments (list name)) - (continue () - :report (lambda (stream) - (write-string (intl:gettext "Ignore the lock and continue") stream))) - (unlock-package () - :report (lambda (stream) - (write-string (intl:gettext "Disable the package's definition-lock then continue") stream)) - (setf (ext:package-definition-lock package) nil)) - (unlock-all () - :report (lambda (stream) - (write-string (intl:gettext "Unlock all packages, then continue") stream)) - (lisp::unlock-all-packages)))))) + ;; Bootstrap: *enable-package-locked-errors* may not be bound while + ;; loading the kernel.core. + (when (and (boundp 'lisp::*enable-package-locked-errors*) + lisp::*enable-package-locked-errors*) + (multiple-value-bind (valid block-name) + (ext:valid-function-name-p name) + (declare (ignore valid)) + (let ((package (symbol-package block-name))) + (when package + (when (ext:package-definition-lock package) + (restart-case + (error 'lisp::package-locked-error + :package package + :format-control (intl:gettext "defining macro ~A") + :format-arguments (list name)) + (continue () + :report (lambda (stream) + (write-string (intl:gettext "Ignore the lock and continue") stream))) + (unlock-package () + :report (lambda (stream) + (write-string (intl:gettext "Disable the package's definition-lock then continue") stream)) + (setf (ext:package-definition-lock package) nil)) + (unlock-all () + :report (lambda (stream) + (write-string (intl:gettext "Unlock all packages, then continue") stream)) + (lisp::unlock-all-packages)))))))) + (clear-info function where-from name) (setf (macro-function name) definition) (setf (documentation name 'function) doc) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7fb7b8d94783418319487666... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7fb7b8d94783418319487666... You're receiving this email because of your account on gitlab.common-lisp.net. Manage all notifications: https://gitlab.common-lisp.net/-/profile/notifications | Help: https://gitlab.common-lisp.net/help
participants (1)
-
Raymond Toy (@rtoy)