source: trunk/j/src/org/armedbear/lisp/package.lisp @ 11294

Last change on this file since 11294 was 11294, checked in by ehuelsmann, 15 years ago

Fix IMPORT.ERROR.4 and IMPORT.ERROR.5 ansi-tests.

(We're now at 60 failing tests.)

File size: 2.2 KB
Line 
1;;; package.lisp
2;;;
3;;; Copyright (C) 2008 Erik Huelsmann
4;;; $Id: parse-integer.lisp,v 1.4 2003-09-08 13:35:25 piso Exp $
5;;;
6;;; This program is free software; you can redistribute it and/or
7;;; modify it under the terms of the GNU General Public License
8;;; as published by the Free Software Foundation; either version 2
9;;; of the License, or (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20(in-package "SYSTEM")
21
22;; Redefines make-package from boot.lisp
23
24(defun make-package (name &key nicknames use)
25  (restart-case
26      (progn
27        (when (find-package name)
28          (error 'simple-error "Package ~A already exists." name))
29        (dolist (nick nicknames)
30          (when (find-package nick)
31            (error 'package-error :package nick)))
32        (%make-package name nicknames use))
33    (use-existing-package ()
34      :report "Use existing package"
35      (return-from make-package (find-package name)))))
36
37(defun import (symbols &optional (package *package* package-supplied-p))
38  (dolist (symbol (if (listp symbols) symbols (list symbols)))
39    (let* ((sym-name (string symbol))
40           (local-sym (find-symbol sym-name package)))
41      (restart-case
42          (progn
43            (when (and local-sym (not (eql symbol local-sym)))
44              (error 'package-error (format nil "Symbol ~S already accessible in package ~S." local-sym (package-name package))))
45            (if package-supplied-p
46                (%import symbol package)
47                (%import symbol)))
48        (unintern-existing ()
49          :report (lambda (s) (format s "Unintern ~S and continue" local-sym))
50          (unintern local-sym)
51          (%import symbol))
52        (skip ()
53          :report "Skip symbol"))))
54  T)
Note: See TracBrowser for help on using the repository browser.