X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-package.lisp;h=f85db1602af4263794ec3e958bb92e2dc1e4a916;hb=0b96758f3645dff3e681d82cc97ddab1faae27ac;hp=074e43d2a8d163ab18bb611271f1548c663c33d2;hpb=ff92598854bf7cae8d57fe49cef4d9a98e1ab345;p=sbcl.git diff --git a/src/code/target-package.lisp b/src/code/target-package.lisp index 074e43d..f85db16 100644 --- a/src/code/target-package.lisp +++ b/src/code/target-package.lisp @@ -152,35 +152,35 @@ error if any of PACKAGES is not a valid package designator." (defun package-lock-violation (package &key (symbol nil symbol-p) format-control format-arguments) - (let ((restart :continue) - (cl-violation-p (eq package (find-package :common-lisp)))) - (flet ((error-arguments () - (append (list (if symbol-p - 'symbol-package-locked-error - 'package-locked-error) - :package package - :format-control format-control - :format-arguments format-arguments) - (when symbol-p (list :symbol symbol)) - (list :references - (append '((:sbcl :node "Package Locks")) - (when cl-violation-p - '((:ansi-cl :section (11 1 2 1 2))))))))) - (restart-case - (apply #'cerror "Ignore the package lock." (error-arguments)) - (:ignore-all () - :report "Ignore all package locks in the context of this operation." - (setf restart :ignore-all)) - (:unlock-package () - :report "Unlock the package." - (setf restart :unlock-package))) - (ecase restart - (:continue - (pushnew package *ignored-package-locks*)) - (:ignore-all - (setf *ignored-package-locks* t)) - (:unlock-package - (unlock-package package)))))) + (let* ((restart :continue) + (cl-violation-p (eq package *cl-package*)) + (error-arguments + (append (list (if symbol-p + 'symbol-package-locked-error + 'package-locked-error) + :package package + :format-control format-control + :format-arguments format-arguments) + (when symbol-p (list :symbol symbol)) + (list :references + (append '((:sbcl :node "Package Locks")) + (when cl-violation-p + '((:ansi-cl :section (11 1 2 1 2))))))))) + (restart-case + (apply #'cerror "Ignore the package lock." error-arguments) + (:ignore-all () + :report "Ignore all package locks in the context of this operation." + (setf restart :ignore-all)) + (:unlock-package () + :report "Unlock the package." + (setf restart :unlock-package))) + (ecase restart + (:continue + (pushnew package *ignored-package-locks*)) + (:ignore-all + (setf *ignored-package-locks* t)) + (:unlock-package + (unlock-package package))))) (defun package-lock-violation-p (package &optional (symbol nil symbolp)) ;; KLUDGE: (package-lock package) needs to be before @@ -477,20 +477,15 @@ error if any of PACKAGES is not a valid package designator." (push n (package-%nicknames package))) ((eq found package)) ((string= (the string (package-%name found)) n) - ;; FIXME: This and the next error needn't have restarts. - (with-simple-restart (continue "Ignore this nickname.") - (error 'simple-package-error - :package package - :format-control "~S is a package name, so it cannot be a nickname for ~S." - :format-arguments (list n (package-%name package))))) + (error 'simple-package-error + :package package + :format-control "~S is a package name, so it cannot be a nickname for ~S." + :format-arguments (list n (package-%name package)))) (t - (with-simple-restart (continue "Redefine this nickname.") - (error 'simple-package-error - :package package - :format-control "~S is already a nickname for ~S." - :format-arguments (list n (package-%name found)))) - (setf (gethash n *package-names*) package) - (push n (package-%nicknames package))))))) + (error 'simple-package-error + :package package + :format-control "~S is already a nickname for ~S." + :format-arguments (list n (package-%name found)))))))) (defun make-package (name &key (use '#.*default-package-use-list*) @@ -550,7 +545,7 @@ error if any of PACKAGES is not a valid package designator." #!+sb-doc "Changes the name and nicknames for a package." (let* ((package (find-undeleted-package-or-lose package)) - (name (string name)) + (name (package-namify name)) (found (find-package name)) (nicks (mapcar #'string nicknames))) (unless (or (not found) (eq found package)) @@ -575,19 +570,23 @@ error if any of PACKAGES is not a valid package designator." (enter-new-nicknames package nicknames)) package)) -(defun delete-package (package-or-name) +(defun delete-package (package-designator) #!+sb-doc - "Delete the package-or-name from the package system data structures." - (let ((package (if (packagep package-or-name) - package-or-name - (find-package package-or-name)))) + "Delete the package designated by PACKAGE-DESIGNATOR from the package + system data structures." + (let ((package (if (packagep package-designator) + package-designator + (find-package package-designator)))) (cond ((not package) ;; This continuable error is required by ANSI. - (with-simple-restart (continue "Return NIL") - (error 'simple-package-error - :package package-or-name - :format-control "There is no package named ~S." - :format-arguments (list package-or-name)))) + (cerror + "Return ~S." + (make-condition + 'simple-package-error + :package package-designator + :format-control "There is no package named ~S." + :format-arguments (list package-designator)) + nil)) ((not (package-name package)) ; already deleted nil) (t @@ -596,15 +595,16 @@ error if any of PACKAGES is not a valid package designator." (let ((use-list (package-used-by-list package))) (when use-list ;; This continuable error is specified by ANSI. - (with-simple-restart - (continue "Remove dependency in other packages.") - (error 'simple-package-error - :package package - :format-control - "Package ~S is used by package(s):~% ~S" - :format-arguments - (list (package-name package) - (mapcar #'package-name use-list)))) + (cerror + "Remove dependency in other packages." + (make-condition + 'simple-package-error + :package package + :format-control + "~@" + :format-arguments (list (package-name package) + (length use-list) + (mapcar #'package-name use-list)))) (dolist (p use-list) (unuse-package package p)))) (dolist (used (package-use-list package)) @@ -642,7 +642,8 @@ error if any of PACKAGES is not a valid package designator." (defun intern (name &optional (package (sane-package))) #!+sb-doc - "Return a symbol having the specified name, creating it if necessary." + "Return a symbol in PACKAGE having the specified NAME, creating it + if necessary." ;; We just simple-stringify the name and call INTERN*, where the real ;; logic is. (let ((name (if (simple-string-p name) @@ -656,8 +657,8 @@ error if any of PACKAGES is not a valid package designator." (defun find-symbol (name &optional (package (sane-package))) #!+sb-doc - "Return the symbol named String in Package. If such a symbol is found - then the second value is :internal, :external or :inherited to indicate + "Return the symbol named STRING in PACKAGE. If such a symbol is found + then the second value is :INTERNAL, :EXTERNAL or :INHERITED to indicate how the symbol is accessible. If no symbol is found then both values are NIL." ;; We just simple-stringify the name and call FIND-SYMBOL*, where the @@ -715,7 +716,7 @@ error if any of PACKAGES is not a valid package designator." (shiftf (cdr prev) (cdr table) (cdr head) table)) (return-from find-symbol* (values symbol :inherited)))))))) -;;; Similar to Find-Symbol, but only looks for an external symbol. +;;; Similar to FIND-SYMBOL, but only looks for an external symbol. ;;; This is used for fast name-conflict checking in this file and symbol ;;; printing in the printer. (defun find-external-symbol (string package) @@ -728,12 +729,145 @@ error if any of PACKAGES is not a valid package designator." string length hash ehash) (values symbol found)))) +(define-condition name-conflict (reference-condition package-error) + ((function :initarg :function :reader name-conflict-function) + (datum :initarg :datum :reader name-conflict-datum) + (symbols :initarg :symbols :reader name-conflict-symbols)) + (:default-initargs :references (list '(:ansi-cl :section (11 1 1 2 5)))) + (:report + (lambda (c s) + (format s "~@<~S ~S causes name-conflicts in ~S between the ~ + following symbols:~2I~@:_~{~S~^, ~}~:@>" + (name-conflict-function c) + (name-conflict-datum c) + (package-error-package c) + (name-conflict-symbols c))))) + +(defun name-conflict (package function datum &rest symbols) + (restart-case + (error 'name-conflict :package package :symbols symbols + :function function :datum datum) + (resolve-conflict (s) + :report "Resolve conflict." + :interactive + (lambda () + (let* ((len (length symbols)) + (nlen (length (write-to-string len :base 10)))) + (format *query-io* "~&~@