;; when we call this as a function, the symbol is resolved before the ;; body is evaluated, so we get the symbol from the current package as ;; the argument for the function, even if the function itself tries to ;; evaluate it elsewhere. the silly solution would be to extract the ;; symbol name from what we get and find it in the package we went to, ;; but it should be smarter to use a macro and resolve the symbols in ;; the latest moment possible (defun with-current-package (sexp package) (when (or (stringp package) (symbolp package)) (setq package (find-package package))) (let ((previous-current-package COMMON-LISP::*PACKAGE*)) (setf COMMON-LISP::*PACKAGE* package) (print COMMON-LISP::*PACKAGE*) (eval sexp) (setf *package* previous-current-package)))