common-lispread-eval-print-loopslime

When I reset Slime, recompile and reinstall packages - why?


I have a SBCL package called frosty.

I am using SLIME with emacs. When I close emacs for the day, and then open it the next day, it's as if I am "starting again".

All my quicklisp packages need to be reloaded. And my frosty package needs to be compiled manually.

Is there a way to have the REPL automatically understand the packages/QL packages from the start?

Thanks


Solution

  • You can define a system to group your files as a unit that can be compiled as a whole, and once it is compiled once, the resulting object files are stored in cache and loaded faster the next time (without compilation).

    defsystem

    At the root of your frosty directory, you can add an ASDF system definition. It contains the following at minimum:

    (defsystem "frosty"
    
        ;; system dependencies:
        ;; those are system names, not package names; they often are
        ;; identical but in general a system can define zero, one or
        ;; more packages
        :depends-on ("alexandria"
                     "cl-ppcre" 
                     ;; etc.
                    )
    
        ;; this declares a list of component, here there is a single entry, 
        ;; namely (:file "frosty") which represents a Lisp source file.
        ;; If you organized your files differently, e.g. under a src/ directory,
        ;; you need to add a :pathname option.
        ;; See https://asdf.common-lisp.dev/asdf.html#The-defsystem-grammar
        :components ((:file "frosty"))
    )
    
    

    What we want to do is be able to call:

    (ql:quickload "frosty")
    

    And have Quicklisp install all the dependencies and your own system.

    In order for quicklisp to know about your .asd file, your project needs to be visible in the quicklisp/local-projects directory. Alternatively, you can choose to link your project under ~/common-lisp/ directory, or any other directory searched by the ASDF central registry (see documentation).

    .sbclrc

    In your ~/.sbclrc init file, you can add expressions to be evaluated, and in particular you can write (ql:quickload "frosty") here so that it is executed each time SBCL is started.