summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-06-19 08:59:07 -0700
committercolin <colin@cicadas.surf>2024-06-19 08:59:07 -0700
commit5822dcfcfec66596bd4745e6f8450e6a824f6082 (patch)
tree870d0b9a5b62435286bf010e215e68c640218c1d
parent2111f61524e5fbdf843950de60740f3a15b5274f (diff)
Fix: def:const only handles errors redefining constants
-rw-r--r--def.lisp15
1 files changed, 8 insertions, 7 deletions
diff --git a/def.lisp b/def.lisp
index c4ab58b..715ab7f 100644
--- a/def.lisp
+++ b/def.lisp
@@ -18,13 +18,14 @@ easily document uninitialized special variables."
"Define a constant in a way that is redefinable whenever the form is
reevaluated."
(assert (good-muffed-var-name-p name :muffer "+"))
- `(progn
- (handler-bind ((error
- (lambda (&rest ignore)
- (declare (ignore ignore))
- (invoke-restart 'cl:continue))))
- (makunbound ',name))
- (defconstant ,name ,value ,@(when doc (list doc)))))
+ (let ((newval (gensym "NEWVAL-")))
+ `(let ((,newval ,value))
+ (handler-bind ((error
+ (lambda (&rest ignore)
+ (declare (ignore ignore))
+ (invoke-restart 'cl:continue))))
+ (makunbound ',name))
+ (defconstant ,name ,newval ,@(when doc (list doc))))))
(defmacro class (name (&rest supers) &body slots-and-options)
"Define a class.