diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/variables-with-restricted-values.html | |
new repository
Diffstat (limited to 'devdocs/elisp/variables-with-restricted-values.html')
| -rw-r--r-- | devdocs/elisp/variables-with-restricted-values.html | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/devdocs/elisp/variables-with-restricted-values.html b/devdocs/elisp/variables-with-restricted-values.html new file mode 100644 index 00000000..a8743b03 --- /dev/null +++ b/devdocs/elisp/variables-with-restricted-values.html @@ -0,0 +1,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 © 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> |
