From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/compiling-macros.html | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 devdocs/elisp/compiling-macros.html (limited to 'devdocs/elisp/compiling-macros.html') 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 @@ +

Macros and Byte Compilation

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.

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.

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 defmacro form, the macro is defined temporarily for the rest of the compilation of that file.

Byte-compiling a file also executes any require 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 Named Features). To avoid loading the macro definition files when someone runs the compiled program, write eval-when-compile around the require calls (see Eval During Compile).

+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html +

+
-- cgit v1.2.3