X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fcode%2Ftarget-package.lisp;h=d8355459751e9076044a25405d2eac44c818c996;hb=cb79d726de3e18c660f84c58a43f00d22b459037;hp=20190239e2b94266c47cdd5bfb6cabf566023da8;hpb=fea8ea02847ddc0864546a02480fb3e97d6fa318;p=sbcl.git diff --git a/src/code/target-package.lisp b/src/code/target-package.lisp index 2019023..d835545 100644 --- a/src/code/target-package.lisp +++ b/src/code/target-package.lisp @@ -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* "~&~@