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/simple-macro.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 devdocs/elisp/simple-macro.html (limited to 'devdocs/elisp/simple-macro.html') diff --git a/devdocs/elisp/simple-macro.html b/devdocs/elisp/simple-macro.html new file mode 100644 index 00000000..b2e75c46 --- /dev/null +++ b/devdocs/elisp/simple-macro.html @@ -0,0 +1,11 @@ +

A Simple Example of a Macro

Suppose we would like to define a Lisp construct to increment a variable value, much like the ++ operator in C. We would like to write (inc x) and have the effect of (setq x (1+ x)). Here’s a macro definition that does the job:

(defmacro inc (var)
+   (list 'setq var (list '1+ var)))
+
+

When this is called with (inc x), the argument var is the symbol xnot the value of x, as it would be in a function. The body of the macro uses this to construct the expansion, which is (setq x (1+ x)). Once the macro definition returns this expansion, Lisp proceeds to evaluate it, thus incrementing x.

Function: macrop object +

This predicate tests whether its argument is a macro, and returns t if so, nil otherwise.

+
+

+ 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/Simple-Macro.html +

+
-- cgit v1.2.3