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/symbol-type.html | |
new repository
Diffstat (limited to 'devdocs/elisp/symbol-type.html')
| -rw-r--r-- | devdocs/elisp/symbol-type.html | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/devdocs/elisp/symbol-type.html b/devdocs/elisp/symbol-type.html new file mode 100644 index 00000000..cc5c9922 --- /dev/null +++ b/devdocs/elisp/symbol-type.html @@ -0,0 +1,20 @@ + <h4 class="subsection">Symbol Type</h4> <p>A <em>symbol</em> in GNU Emacs Lisp is an object with a name. The symbol name serves as the printed representation of the symbol. In ordinary Lisp use, with one single obarray (see <a href="creating-symbols">Creating Symbols</a>), a symbol’s name is unique—no two symbols have the same name. </p> <p>A symbol can serve as a variable, as a function name, or to hold a property list. Or it may serve only to be distinct from all other Lisp objects, so that its presence in a data structure may be recognized reliably. In a given context, usually only one of these uses is intended. But you can use one symbol in all of these ways, independently. </p> <p>A symbol whose name starts with a colon (‘<samp>:</samp>’) is called a <em>keyword symbol</em>. These symbols automatically act as constants, and are normally used only by comparing an unknown symbol with a few specific alternatives. See <a href="constant-variables">Constant Variables</a>. </p> <p>A symbol name can contain any characters whatever. Most symbol names are written with letters, digits, and the punctuation characters ‘<samp>-+=*/</samp>’. Such names require no special punctuation; the characters of the name suffice as long as the name does not look like a number. (If it does, write a ‘<samp>\</samp>’ at the beginning of the name to force interpretation as a symbol.) The characters ‘<samp>_~!@$%^&:<>{}?</samp>’ are less often used but also require no special punctuation. Any other characters may be included in a symbol’s name by escaping them with a backslash. In contrast to its use in strings, however, a backslash in the name of a symbol simply quotes the single character that follows the backslash. For example, in a string, ‘<samp>\t</samp>’ represents a tab character; in the name of a symbol, however, ‘<samp>\t</samp>’ merely quotes the letter ‘<samp>t</samp>’. To have a symbol with a tab character in its name, you must actually use a tab (preceded with a backslash). But it’s rare to do such a thing. </p> <blockquote> <p><b>Common Lisp note:</b> In Common Lisp, lower case letters are always folded to upper case, unless they are explicitly escaped. In Emacs Lisp, upper case and lower case letters are distinct. </p> +</blockquote> <p>Here are several examples of symbol names. Note that the ‘<samp>+</samp>’ in the fourth example is escaped to prevent it from being read as a number. This is not necessary in the sixth example because the rest of the name makes it invalid as a number. </p> <div class="example"> <pre class="example">foo ; <span class="roman">A symbol named ‘<samp>foo</samp>’.</span> +FOO ; <span class="roman">A symbol named ‘<samp>FOO</samp>’, different from ‘<samp>foo</samp>’.</span> +</pre> +<pre class="example">1+ ; <span class="roman">A symbol named ‘<samp>1+</samp>’</span> + ; <span class="roman">(not ‘<samp>+1</samp>’, which is an integer).</span> +</pre> +<pre class="example">\+1 ; <span class="roman">A symbol named ‘<samp>+1</samp>’</span> + ; <span class="roman">(not a very readable name).</span> +</pre> +<pre class="example">\(*\ 1\ 2\) ; <span class="roman">A symbol named ‘<samp>(* 1 2)</samp>’ (a worse name).</span> ++-*/_~!@$%^&=:<>{} ; <span class="roman">A symbol named ‘<samp>+-*/_~!@$%^&=:<>{}</samp>’.</span> + ; <span class="roman">These characters need not be escaped.</span> +</pre> +</div> <p>As an exception to the rule that a symbol’s name serves as its printed representation, ‘<samp>##</samp>’ is the printed representation for an interned symbol whose name is an empty string. Furthermore, ‘<samp>#:<var>foo</var></samp>’ is the printed representation for an uninterned symbol whose name is <var>foo</var>. (Normally, the Lisp reader interns all symbols; see <a href="creating-symbols">Creating Symbols</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-Type.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Type.html</a> + </p> +</div> |
