Switch package
Posted: Mon Mar 21, 2011 4:26 am
Hi!
I am trying to write a macro, which dynamically binds the current package:
which expands like this:
but evaluating it gives me an error [SBCL]:
but this works:
The macro IN-PACKAGE does nothing else than setting the value of *PACKAGE* (http://www.lispworks.com/documentation/ ... in_pkg.htm).
What do I miss?
I am trying to write a macro, which dynamically binds the current package:
Code: Select all
(defmacro with-in-package (package-designator &body body)
`(let ((*package* (find-package ,package-designator)))
,@body))
Code: Select all
(macroexpand-1 '(with-in-package :sb-cltl2 (variable-information '*package*)))
(LET ((*PACKAGE* (FIND-PACKAGE :SB-CLTL2)))
(VARIABLE-INFORMATION '*PACKAGE*))
Code: Select all
(with-in-package :sb-cltl2 (variable-information '*package*))
->The function VARIABLE-INFORMATION is undefined.
Code: Select all
(sb-cltl2:variable-information '*package*)
:SPECIAL
NIL
((TYPE . PACKAGE))
What do I miss?