summaryrefslogtreecommitdiff
path: root/devdocs/elisp/constant-variables.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/constant-variables.html
new repository
Diffstat (limited to 'devdocs/elisp/constant-variables.html')
-rw-r--r--devdocs/elisp/constant-variables.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/constant-variables.html b/devdocs/elisp/constant-variables.html
new file mode 100644
index 00000000..fd0538ba
--- /dev/null
+++ b/devdocs/elisp/constant-variables.html
@@ -0,0 +1,14 @@
+ <h3 class="section">Variables that Never Change</h3> <p>In Emacs Lisp, certain symbols normally evaluate to themselves. These include <code>nil</code> and <code>t</code>, as well as any symbol whose name starts with ‘<samp>:</samp>’ (these are called <em>keywords</em>). These symbols cannot be rebound, nor can their values be changed. Any attempt to set or bind <code>nil</code> or <code>t</code> signals a <code>setting-constant</code> error. The same is true for a keyword (a symbol whose name starts with ‘<samp>:</samp>’), if it is interned in the standard obarray, except that setting such a symbol to itself is not an error. </p> <div class="example"> <pre class="example">nil ≡ 'nil
+ ⇒ nil
+</pre>
+<pre class="example">(setq nil 500)
+error→ Attempt to set constant symbol: nil
+</pre>
+</div> <dl> <dt id="keywordp">Function: <strong>keywordp</strong> <em>object</em>
+</dt> <dd><p>function returns <code>t</code> if <var>object</var> is a symbol whose name starts with ‘<samp>:</samp>’, interned in the standard obarray, and returns <code>nil</code> otherwise. </p></dd>
+</dl> <p>These constants are fundamentally different from the constants defined using the <code>defconst</code> special form (see <a href="defining-variables">Defining Variables</a>). A <code>defconst</code> form serves to inform human readers that you do not intend to change the value of a variable, but Emacs does not raise an error if you actually change it. </p> <p>A small number of additional symbols are made read-only for various practical reasons. These include <code>enable-multibyte-characters</code>, <code>most-positive-fixnum</code>, <code>most-negative-fixnum</code>, and a few others. Any attempt to set or bind these also signals a <code>setting-constant</code> error. </p><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/Constant-Variables.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Constant-Variables.html</a>
+ </p>
+</div>