Initial revision
[sbcl.git] / src / cold / rename-package-carefully.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB-COLD")
11
12 ;;;; $Header$
13
14 ;;; RENAME-PACKAGE in two steps in order to avoid the possibility of undefined
15 ;;; behavior when one of the new names is the same as one of the old names.
16 ;;; (ANSI on RENAME-PACKAGE: "The consequences are undefined if new-name or any
17 ;;; new-nickname conflicts with any existing package names.")
18 (defun rename-package-carefully (package-designator
19                                  new-name
20                                  &optional new-nicknames)
21   (let ((package (find-package package-designator))
22         (unused-name "UNUSED-PACKAGE-NAME"))
23     (assert (not (find-package unused-name)))
24     (assert (not (string= unused-name new-name)))
25     (assert (not (find unused-name new-nicknames :test #'string=)))
26     (assert (not (find new-name new-nicknames :test #'string=)))
27     (rename-package package unused-name)
28     (rename-package package new-name new-nicknames)))
29 (compile 'rename-package-carefully)