summaryrefslogtreecommitdiff
path: root/devdocs/elisp/compiling-macros.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/compiling-macros.html
new repository
Diffstat (limited to 'devdocs/elisp/compiling-macros.html')
-rw-r--r--devdocs/elisp/compiling-macros.html6
1 files changed, 6 insertions, 0 deletions
diff --git a/devdocs/elisp/compiling-macros.html b/devdocs/elisp/compiling-macros.html
new file mode 100644
index 00000000..34b5e951
--- /dev/null
+++ b/devdocs/elisp/compiling-macros.html
@@ -0,0 +1,6 @@
+ <h3 class="section">Macros and Byte Compilation</h3> <p>You might ask why we take the trouble to compute an expansion for a macro and then evaluate the expansion. Why not have the macro body produce the desired results directly? The reason has to do with compilation. </p> <p>When a macro call appears in a Lisp program being compiled, the Lisp compiler calls the macro definition just as the interpreter would, and receives an expansion. But instead of evaluating this expansion, it compiles the expansion as if it had appeared directly in the program. As a result, the compiled code produces the value and side effects intended for the macro, but executes at full compiled speed. This would not work if the macro body computed the value and side effects itself—they would be computed at compile time, which is not useful. </p> <p>In order for compilation of macro calls to work, the macros must already be defined in Lisp when the calls to them are compiled. The compiler has a special feature to help you do this: if a file being compiled contains a <code>defmacro</code> form, the macro is defined temporarily for the rest of the compilation of that file. </p> <p>Byte-compiling a file also executes any <code>require</code> calls at top-level in the file, so you can ensure that necessary macro definitions are available during compilation by requiring the files that define them (see <a href="named-features">Named Features</a>). To avoid loading the macro definition files when someone <em>runs</em> the compiled program, write <code>eval-when-compile</code> around the <code>require</code> calls (see <a href="eval-during-compile">Eval During Compile</a>). </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/Compiling-Macros.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html</a>
+ </p>
+</div>