[slime-devel] What's the difference between compile and load?

E'Chao Zhang echaozh at gmail.com
Thu Mar 1 20:50:13 UTC 2007

Thomas F. Burdick wrote:
> This isn't a Slime issue as much as in implementation one.  You don't
> say what Lisp you're using, but I assume it's SBCL, as that matches
> the behavior you described.
> The problem is that compiling a form *may* cause the things it defines
> to become defined, and in the case of constants and SBCL, it does.
> Then when you load the file, it gets redefined.  Which is fine if the
> constant was 3, but not if it was '(1 2 3).
> A common solution is to do something like:
>  (defmacro defconstant-equal (var value &optional doc)
>    `(defconstant ,var
>                  (if (not (boundp ',var))
>                      ,value
>                      (let ((old (symbol-value ',var))
>                            (new ,value))
>                        (if (equal old new)
>                            old
>                            (prog1 new
>                              (cerror "Redefine it anyway"
>                                      "New value ~S for constant ~S is
> not equal to old value ~S"
>                                      new ',var old)))))
>                  ,@(when doc (list doc))))
> Then use defconstant-equal instead of defconstant.  Or just use 
> defparameter.
Well, I didn't quite expect it to be a problem of Slime... but I thought 
it may have something to do with it... and it's an active list : )

Thanks for the great explanation, I should try it.

More information about the slime-devel mailing list