[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] Re: a little more info
From: |
Pascal Bourguignon |
Subject: |
Re: [Gcl-devel] Re: a little more info |
Date: |
Thu, 8 Jun 2006 07:41:40 +0200 |
Camm Maguire writes:
> Greetings, and thanks for this!
>
> I think if you delete the home package of a symbol, there is nothing
> you can do, even with imports or exports.
You cannot find the symbols, but if you have a reference on them, you
can still import them!
> >(symbol-package 'define-symbol-macro)
>
> #<"COMMON-LISP-USER" package>
>
> >(delete-package 'common-lisp-user)
>
> T
>
> NIL>(symbol-package 'define-symbol-macro)
>
> #<NIL package>
>
> ... but I am clueless about packages, so this could be quite wrong.
Well, I would have expected the later to fail because there's no
package where to read the form, but we're in implementation specific
behavior. clisp just falls back to COMMON-LISP.
[1]> (symbol-package 'define-symbol-macro)
#<PACKAGE COMMON-LISP>
[2]> (delete-package *package*)
** - Continuable Error
The value of *PACKAGE* was not a package and was reset. The old value was
#<DELETED PACKAGE COMMON-LISP-USER>
. The new value is #<PACKAGE COMMON-LISP>.
If you continue (by typing 'continue'): Proceed with the new value.
The following restarts are also available:
ABORT :R1 ABORT
Break 1 CL[3]> :a
CL[4]>
Clearly gcl uses the trick of having a NIL package, that still uses
COMMON-LISP and in which the second DEFINE-SYMBOL-MACRO is interned.
In gcl:
>(let ((sym (intern "NEW-SYMBOL-FROM-HERE" *package*)))
(delete-package *package*)
(setf *package* (make-package "MY-OWN-NEW-PACKAGE" :use
'("COMMON-LISP")))
(print `(home package of ,sym = ,(symbol-package sym)))
(import sym *package*)
(print `(home package of ,sym = ,(symbol-package sym)))
(find-symbol "NEW-SYMBOL-FROM-HERE" *package*))
(NIL::HOME PACKAGE NIL::OF NIL::NEW-SYMBOL-FROM-HERE = #<NIL package>)
(NIL::HOME PACKAGE NIL::OF NEW-SYMBOL-FROM-HERE = #<NIL package>)
NEW-SYMBOL-FROM-HERE
:INTERNAL
MY-OWN-NEW-PACKAGE>
In clisp:
[1]> (let ((sym (intern "NEW-SYMBOL-FROM-HERE" *package*)))
(delete-package *package*)
(setf *package* (make-package "MY-OWN-NEW-PACKAGE" :use
'("COMMON-LISP")))
(print `(home package of ,sym = ,(symbol-package sym)))
(import sym *package*)
(print `(home package of ,sym = ,(symbol-package sym)))
(find-symbol "NEW-SYMBOL-FROM-HERE" *package*))
(#:HOME PACKAGE #:OF #:NEW-SYMBOL-FROM-HERE = NIL)
(#:HOME PACKAGE #:OF NEW-SYMBOL-FROM-HERE = #<PACKAGE MY-OWN-NEW-PACKAGE>)
NEW-SYMBOL-FROM-HERE ;
:INTERNAL
MY-OWN-NEW-PACKAGE[2]>
(clisp gives the homeless symbols a new home when imported...)
--
__Pascal Bourguignon__ http://www.informatimago.com/
"Our users will know fear and cower before our software! Ship it!
Ship it and let them flee like the dogs they are!"