When I redefine constants (eg when reloading a package I am working
on), SBCL complains. From [1] I understand that the complaint is
legitimate, but I would like to avoid it.
My (automatically generated) Lisp file looks like this [2]:
(defstruct rgb-color red green blue)
(defmacro define-rgb-color (name red green blue)
`(progn
(defconstant ,name (make-rgb-color :red ,red :green ,green :blue ,blue))
(export ',name)))
(define-rgb-color +snow+ 1.0d0 0.9803921568627451d0 0.9803921568627451d0)
(define-rgb-color +ghostwhite+ 0.9725490196078431d0 0.9725490196078431d0 1.0d0)
... (more than 650 definitions)
The SBCL manual suggests that "the programmer can handle the condition
type sb-ext:defconstant-uneql, and choose either the continue or abort
restart as appropriate". I am still working on understanding
conditions, could someone help me out with this so I could wrap the
whole file in some expression which would suppress the warnings?
Thanks,
Tamas
[1] http://www.sbcl.org/manual/Defining-Constants.html
[2] Yes, I know, exports should be in the defsystem, all in one place,
but I every other export is there except the list of named colors,
which is in a single file.
Tamas Papp <······@gmail.com> writes:
> The SBCL manual suggests that "the programmer can handle the condition
> type sb-ext:defconstant-uneql, and choose either the continue or abort
> restart as appropriate". I am still working on understanding
> conditions, could someone help me out with this so I could wrap the
> whole file in some expression which would suppress the warnings?
That suggestion comes last. The previous suggestions are probably
easier to use, particularly:
(defmacro define-constant (name value &optional doc)
`(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
,@(when doc (list doc))))
Zach
On Jul 22, 1:55 pm, Zach Beane <····@xach.com> wrote:
> Tamas Papp <······@gmail.com> writes:
> > The SBCL manual suggests that "the programmer can handle the condition
> > type sb-ext:defconstant-uneql, and choose either the continue or abort
> > restart as appropriate". I am still working on understanding
> > conditions, could someone help me out with this so I could wrap the
> > whole file in some expression which would suppress the warnings?
>
> That suggestion comes last. The previous suggestions are probably
> easier to use, particularly:
>
> (defmacro define-constant (name value &optional doc)
> `(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
> ,@(when doc (list doc))))
Or even better, instead of (boundp ',name) use something like (and
(boundp ',name) (equal (symbol-value ',name) ,value))