[developers] compiling rms in sbcl
Ben Waldron
bmw20 at cl.cam.ac.uk
Fri Sep 8 17:23:13 CEST 2006
Ann Copestake wrote:
> That defconstant *coding-system-names* (last point) concerns me a little
> because Allegro CL does warn of redefinitions of constants and I can't find
> where it is defined elsewhere. defparameter seems like bad style here. It's
> your code, so if you are having to redefine it for some reason, go ahead, but
> you should check what's happening first. maybe you have it set in a personal
> init file, for instance?
>
Apparently, this unhelpful behaviour arises from a strict interpretation
of the ANSI standard. See
http://www.sbcl.org/manual/Defining-Constants.html#Defining-Constants.
In brief: ANSI says that doing |defconstant| of the same symbol more
than once is undefined unless the new value is |eql| to the old value.
SBCL treats this undefined behaviour as an error. This is unfortunate,
because in SBCL defconstant takes effect not only at load time but also
at compile time.
I've worked around this problem using the following macro (taken from
the SBCL manual):
(defmacro define-constant (name value &optional doc)
`(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
,@(when doc (list doc))))
- Ben
More information about the developers
mailing list