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/function-names.html | |
new repository
Diffstat (limited to 'devdocs/elisp/function-names.html')
| -rw-r--r-- | devdocs/elisp/function-names.html | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/devdocs/elisp/function-names.html b/devdocs/elisp/function-names.html new file mode 100644 index 00000000..997eae46 --- /dev/null +++ b/devdocs/elisp/function-names.html @@ -0,0 +1,6 @@ + <h3 class="section">Naming a Function</h3> <p>A symbol can serve as the name of a function. This happens when the symbol’s <em>function cell</em> (see <a href="symbol-components">Symbol Components</a>) contains a function object (e.g., a lambda expression). Then the symbol itself becomes a valid, callable function, equivalent to the function object in its function cell. </p> <p>The contents of the function cell are also called the symbol’s <em>function definition</em>. The procedure of using a symbol’s function definition in place of the symbol is called <em>symbol function indirection</em>; see <a href="function-indirection">Function Indirection</a>. If you have not given a symbol a function definition, its function cell is said to be <em>void</em>, and it cannot be used as a function. </p> <p>In practice, nearly all functions have names, and are referred to by their names. You can create a named Lisp function by defining a lambda expression and putting it in a function cell (see <a href="function-cells">Function Cells</a>). However, it is more common to use the <code>defun</code> special form, described in the next section. See <a href="defining-functions">Defining Functions</a>. </p> <p>We give functions names because it is convenient to refer to them by their names in Lisp expressions. Also, a named Lisp function can easily refer to itself—it can be recursive. Furthermore, primitives can only be referred to textually by their names, since primitive function objects (see <a href="primitive-function-type">Primitive Function Type</a>) have no read syntax. </p> <p>A function need not have a unique name. A given function object <em>usually</em> appears in the function cell of only one symbol, but this is just a convention. It is easy to store it in several symbols using <code>fset</code>; then each of the symbols is a valid name for the same function. </p> <p>Note that a symbol used as a function name may also be used as a variable; these two uses of a symbol are independent and do not conflict. (This is not the case in some dialects of Lisp, like Scheme.) </p> <p>By convention, if a function’s symbol consists of two names separated by ‘<samp>--</samp>’, the function is intended for internal use and the first part names the file defining the function. For example, a function named <code>vc-git--rev-parse</code> is an internal function defined in <samp>vc-git.el</samp>. Internal-use functions written in C have names ending in ‘<samp>-internal</samp>’, e.g., <code>bury-buffer-internal</code>. Emacs code contributed before 2018 may follow other internal-use naming conventions, which are being phased out. </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/Function-Names.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Function-Names.html</a> + </p> +</div> |
