summaryrefslogtreecommitdiff
path: root/devdocs/elisp/nil-and-t.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/nil-and-t.html')
-rw-r--r--devdocs/elisp/nil-and-t.html11
1 files changed, 11 insertions, 0 deletions
diff --git a/devdocs/elisp/nil-and-t.html b/devdocs/elisp/nil-and-t.html
new file mode 100644
index 00000000..f34c2004
--- /dev/null
+++ b/devdocs/elisp/nil-and-t.html
@@ -0,0 +1,11 @@
+ <h4 class="subsection">nil and t</h4> <p>In Emacs Lisp, the symbol <code>nil</code> has three separate meanings: it is a symbol with the name ‘<samp>nil</samp>’; it is the logical truth value <var>false</var>; and it is the empty list—the list of zero elements. When used as a variable, <code>nil</code> always has the value <code>nil</code>. </p> <p>As far as the Lisp reader is concerned, ‘<samp>()</samp>’ and ‘<samp>nil</samp>’ are identical: they stand for the same object, the symbol <code>nil</code>. The different ways of writing the symbol are intended entirely for human readers. After the Lisp reader has read either ‘<samp>()</samp>’ or ‘<samp>nil</samp>’, there is no way to determine which representation was actually written by the programmer. </p> <p>In this manual, we write <code>()</code> when we wish to emphasize that it means the empty list, and we write <code>nil</code> when we wish to emphasize that it means the truth value <var>false</var>. That is a good convention to use in Lisp programs also. </p> <div class="example"> <pre class="example">(cons 'foo ()) ; <span class="roman">Emphasize the empty list</span>
+(setq foo-flag nil) ; <span class="roman">Emphasize the truth value <var>false</var></span>
+</pre>
+</div> <p>In contexts where a truth value is expected, any non-<code>nil</code> value is considered to be <var>true</var>. However, <code>t</code> is the preferred way to represent the truth value <var>true</var>. When you need to choose a value that represents <var>true</var>, and there is no other basis for choosing, use <code>t</code>. The symbol <code>t</code> always has the value <code>t</code>. </p> <p>In Emacs Lisp, <code>nil</code> and <code>t</code> are special symbols that always evaluate to themselves. This is so that you do not need to quote them to use them as constants in a program. An attempt to change their values results in a <code>setting-constant</code> error. See <a href="constant-variables">Constant Variables</a>. </p> <dl> <dt id="booleanp">Function: <strong>booleanp</strong> <em>object</em>
+</dt> <dd><p>Return non-<code>nil</code> if <var>object</var> is one of the two canonical boolean values: <code>t</code> or <code>nil</code>. </p></dd>
+</dl><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/nil-and-t.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/nil-and-t.html</a>
+ </p>
+</div>