summaryrefslogtreecommitdiff
path: root/devdocs/elisp/variables-with-restricted-values.html
blob: a8743b03497b3ecc94c7c853dd25a77781016948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 <h3 class="section">Variables with Restricted Values</h3>  <p>Ordinary Lisp variables can be assigned any value that is a valid Lisp object. However, certain Lisp variables are not defined in Lisp, but in C. Most of these variables are defined in the C code using <code>DEFVAR_LISP</code>. Like variables defined in Lisp, these can take on any value. However, some variables are defined using <code>DEFVAR_INT</code> or <code>DEFVAR_BOOL</code>. See <a href="writing-emacs-primitives#Defining-Lisp-variables-in-C">Writing Emacs Primitives</a>, in particular the description of functions of the type <code>syms_of_<var>filename</var></code>, for a brief discussion of the C implementation. </p> <p>Variables of type <code>DEFVAR_BOOL</code> can only take on the values <code>nil</code> or <code>t</code>. Attempting to assign them any other value will set them to <code>t</code>: </p> <div class="example"> <pre class="example">(let ((display-hourglass 5))
  display-hourglass)
     ⇒ t
</pre>
</div> <dl> <dt id="byte-boolean-vars">Variable: <strong>byte-boolean-vars</strong>
</dt> <dd><p>This variable holds a list of all variables of type <code>DEFVAR_BOOL</code>. </p></dd>
</dl> <p>Variables of type <code>DEFVAR_INT</code> can take on only integer values. Attempting to assign them any other value will result in an error: </p> <div class="example"> <pre class="example">(setq undo-limit 1000.0)
error→ Wrong type argument: integerp, 1000.0
</pre>
</div><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Variables-with-Restricted-Values.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Variables-with-Restricted-Values.html</a>
  </p>
</div>