blob: 7d2da9de206e9c1793e528ceba085554a4a10fff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<h4 class="subsection">Symbol Forms</h4> <p>When a symbol is evaluated, it is treated as a variable. The result is the variable’s value, if it has one. If the symbol has no value as a variable, the Lisp interpreter signals an error. For more information on the use of variables, see <a href="variables">Variables</a>. </p> <p>In the following example, we set the value of a symbol with <code>setq</code>. Then we evaluate the symbol, and get back the value that <code>setq</code> stored. </p> <div class="example"> <pre class="example">(setq a 123)
⇒ 123
</pre>
<pre class="example">(eval 'a)
⇒ 123
</pre>
<pre class="example">a
⇒ 123
</pre>
</div> <p>The symbols <code>nil</code> and <code>t</code> are treated specially, so that the value of <code>nil</code> is always <code>nil</code>, and the value of <code>t</code> is always <code>t</code>; you cannot set or bind them to any other values. Thus, these two symbols act like self-evaluating forms, even though <code>eval</code> treats them like any other symbol. A symbol whose name starts with ‘<samp>:</samp>’ also self-evaluates in the same way; likewise, its value ordinarily cannot be changed. See <a href="constant-variables">Constant Variables</a>. </p><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/Symbol-Forms.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Forms.html</a>
</p>
</div>
|