X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=macros.lisp;h=d0ba63c629d8e698cc011c6072ce82c20e7d604d;hp=c83b3b64a19f9f9be26f9dd96daa9ed9213f6f6d;hb=9e36114ec80a5a8b58a650a5f80b4d51b43d0ce0;hpb=36e2522dde1173c28300156cb718779d5858c36d diff --git a/macros.lisp b/macros.lisp index c83b3b6..d0ba63c 100644 --- a/macros.lisp +++ b/macros.lisp @@ -264,8 +264,16 @@ (format t "~%~%") (values))) -(defmacro defconst (symbol value &optional doc) - `(defconstant ,symbol (if (boundp ',symbol) - (symbol-value ',symbol) - ,value) +(defmacro defconstant* (sym value &optional doc) + "Ensure VALUE is evaluated only once." + `(defconstant ,sym (if (boundp ',sym) + (symbol-value ',sym) + ,value) ,@(when doc (list doc)))) + +(defmacro defvar-unbound (sym &optional (doc "")) + "defvar with a documentation string." + `(progn + (defvar ,sym) + (setf (documentation ',sym 'variable) ,doc))) +