summaryrefslogtreecommitdiff
path: root/devdocs/elisp/quoting.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/quoting.html
new repository
Diffstat (limited to 'devdocs/elisp/quoting.html')
-rw-r--r--devdocs/elisp/quoting.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/devdocs/elisp/quoting.html b/devdocs/elisp/quoting.html
new file mode 100644
index 00000000..8b79401d
--- /dev/null
+++ b/devdocs/elisp/quoting.html
@@ -0,0 +1,26 @@
+ <h3 class="section">Quoting</h3> <p>The special form <code>quote</code> returns its single argument, as written, without evaluating it. This provides a way to include constant symbols and lists, which are not self-evaluating objects, in a program. (It is not necessary to quote self-evaluating objects such as numbers, strings, and vectors.) </p> <dl> <dt id="quote">Special Form: <strong>quote</strong> <em>object</em>
+</dt> <dd><p>This special form returns <var>object</var>, without evaluating it. The returned value might be shared and should not be modified. See <a href="self_002devaluating-forms">Self-Evaluating Forms</a>. </p></dd>
+</dl> <p>Because <code>quote</code> is used so often in programs, Lisp provides a convenient read syntax for it. An apostrophe character (‘<samp>'</samp>’) followed by a Lisp object (in read syntax) expands to a list whose first element is <code>quote</code>, and whose second element is the object. Thus, the read syntax <code>'x</code> is an abbreviation for <code>(quote x)</code>. </p> <p>Here are some examples of expressions that use <code>quote</code>: </p> <div class="example"> <pre class="example">(quote (+ 1 2))
+ ⇒ (+ 1 2)
+</pre>
+<pre class="example">(quote foo)
+ ⇒ foo
+</pre>
+<pre class="example">'foo
+ ⇒ foo
+</pre>
+<pre class="example">''foo
+ ⇒ 'foo
+</pre>
+<pre class="example">'(quote foo)
+ ⇒ 'foo
+</pre>
+<pre class="example">['foo]
+ ⇒ ['foo]
+</pre>
+</div> <p>Although the expressions <code>(list '+ 1 2)</code> and <code>'(+ 1 2)</code> both yield lists equal to <code>(+ 1 2)</code>, the former yields a freshly-minted mutable list whereas the latter yields a list built from conses that might be shared and should not be modified. See <a href="self_002devaluating-forms">Self-Evaluating Forms</a>. </p> <p>Other quoting constructs include <code>function</code> (see <a href="anonymous-functions">Anonymous Functions</a>), which causes an anonymous lambda expression written in Lisp to be compiled, and ‘<samp>`</samp>’ (see <a href="backquote">Backquote</a>), which is used to quote only part of a list, while computing and substituting other parts. </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/Quoting.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Quoting.html</a>
+ </p>
+</div>