I'm using (asdf:load-system "app" :force t)
at the REPL to process an ASD file containing some package definitions and (asdf:defsystem "app" ...)
specifying the file :components. After loading, the REPL is in the :cl-user package. How do you make the REPL end up in a different package instead. Adding (in-package :my-pkg) in various places (eg, ASD or components) has not worked.
Package changes during a load or compile operation don't change the current package for the REPL. That would be very annoying in normal usage. Systems also don't correspond 1-to-1 with packages, so there may not be a package with the same name, and the system may have multiple packages. For development convenience however, you can add a function to your init-file (~/.sbclrc
for SBCL) that loads a system and sets *PACKAGE*
to a package by the same name. For example,
(require :asdf) ;Quicklisp also requires ASDF, so you could put this after its init too
(defun l (system-name)
(asdf:load-system system-name)
(setf *package* (find-package system-name)))
The function will be in the CL-USER
-package. Since this is for development use only, errors for non-existent systems or packages can be handled interactively. Notice that you should call it using a keyword for the name rather than a string, or alternatively string-upcase the name before the call to FIND-PACKAGE
.