X-Git-Url: https://git.distorted.org.uk/~mdw/lisp/blobdiff_plain/d7d819976cb5d84766bffd2c5272c86203687ee9..d6caa73bc6253f7a0461406a939865a207bad7c8:/mdw-base.lisp diff --git a/mdw-base.lisp b/mdw-base.lisp index 2c1a79c..a41b685 100644 --- a/mdw-base.lisp +++ b/mdw-base.lisp @@ -135,6 +135,17 @@ t) (t nil))) +(defmacro defconstant* (name value &key doc test) + "Define a constant, like `defconstant'. The TEST is an equality test used + to decide whether to override the current definition, if any." + (let ((temp (gensym))) + `(eval-when (:compile-toplevel :load-toplevel :execute) + (let ((,temp ,value)) + (unless (and (boundp ',name) + (funcall ,(or test ''eql) (symbol-value ',name) ,temp)) + (defconstant ,name ,value ,@(and doc (list doc)))) + ',name)))) + (declaim (ftype (function nil ()) slot-unitialized)) (defun slot-uninitialized () "A function which signals an error. Can be used as an initializer form in