src/utilities.lisp (defvar-unbound): Make a variable with docs and no value.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 Jun 2018 18:58:28 +0000 (19:58 +0100)
doc/SYMBOLS
doc/misc.tex
src/utilities.lisp

index 43ed0f2..909f993 100644 (file)
@@ -2217,6 +2217,7 @@ utilities.lisp
   default-slot                                  macro
   define-access-wrapper                         macro
   define-on-demand-slot                         macro
+  defvar-unbound                                macro
   designated-condition                          function
   dosequence                                    macro
   sb-mop:eql-specializer                        class
index 2e7b504..f6037e1 100644 (file)
@@ -172,6 +172,9 @@ These symbols are defined in the @|sod-utilities| package.
     {compose @<function> \&rest @<more-functions> @> @<function>}
 \end{describe}
 
+\begin{describe}{mac}{defvar @<name> @<documentation> @> @<name>}
+\end{describe}
+
 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
 \end{describe}
 
index 72423fd..72af8b3 100644 (file)
     (reduce #'compose1 more-functions :initial-value function)))
 
 ;;;--------------------------------------------------------------------------
+;;; Variables.
+
+(export 'defvar-unbound)
+(defmacro defvar-unbound (var doc)
+  "Make VAR a special variable with documentation DOC, but leave it unbound."
+  `(eval-when (:compile-toplevel :load-toplevel :execute)
+     (defvar ,var)
+     (setf (documentation ',var 'variable) ',doc)
+     ',var))
+
+;;;--------------------------------------------------------------------------
 ;;; Symbols.
 
 (export 'symbolicate)