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

139 Views Asked by At

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

2

There are 2 best solutions below

0
coredump On BEST ANSWER

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.

0
ignis volens On

One of the following will work.

  • Don't quit the running lisp / emacs. Only an option if you're able to leave processes running overnight on the machine you're using, but that usually is the case now.
  • Save a core image and restart that: See here and the --core option.
  • Write a little Lisp source file which just reloads everything, perhaps by using a system definition.

The first two are superficially attractive but have the consequence that, over time, you end up running in a world which you only may be able to recreate and which gradually becomes infested by elves (anyone who has used d machines seriously will remember this problem). The last option means you know how to recreate the state of the world, but you have to pay the cost of doing so.

Once upon a time when computers were slower most people did one of the first two. Now they're quick the last seems preferable in many cases.