From 5822dcfcfec66596bd4745e6f8450e6a824f6082 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 19 Jun 2024 08:59:07 -0700 Subject: Fix: def:const only handles errors redefining constants --- def.lisp | 15 ++++++++------- 1 file 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. -- cgit v1.2.3