diff options
author | Glenn Morris <rgm@gnu.org> | 2012-05-04 20:37:30 -0400 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2012-05-04 20:37:30 -0400 |
commit | ddff335186c805b3756cff110033fe118f548f17 (patch) | |
tree | 91b95a190047e233c13feec4cb82fbe34d2c4c14 /doc/lispref/macros.texi | |
parent | 9824f5052394817ac65302d42a7c97841593e19e (diff) | |
download | emacs-ddff335186c805b3756cff110033fe118f548f17.tar.gz |
More small edits for doc/lispref
* control.texi: Where possible, use example rather than smallexample.
(Sequencing, Conditionals, Signaling Errors, Handling Errors):
Tweak page breaks.
* customize.texi: Where possible, use example rather than smallexample.
(Common Keywords, Variable Definitions, Applying Customizations)
(Custom Themes): Tweak page breaks.
* eval.texi, functions.texi, loading.texi, macros.texi:
Where possible, use example rather than smallexample.
* sequences.texi (Arrays): Tweak page breaks.
* symbols.texi: Where possible, use example rather than smallexample.
(Symbol Components): Fix typo.
(Other Plists): Tweak page break.
Diffstat (limited to 'doc/lispref/macros.texi')
-rw-r--r-- | doc/lispref/macros.texi | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/doc/lispref/macros.texi b/doc/lispref/macros.texi index b87e9f228f3..5cdcfae1e50 100644 --- a/doc/lispref/macros.texi +++ b/doc/lispref/macros.texi @@ -1,6 +1,6 @@ @c -*-texinfo-*- @c This is part of the GNU Emacs Lisp Reference Manual. -@c Copyright (C) 1990-1995, 1998, 2001-2012 Free Software Foundation, Inc. +@c Copyright (C) 1990-1995, 1998, 2001-2012 Free Software Foundation, Inc. @c See the file elisp.texi for copying conditions. @setfilename ../../info/macros @node Macros, Customization, Functions, Top @@ -110,7 +110,7 @@ If @var{environment} is provided, it specifies an alist of macro definitions that shadow the currently defined macros. Byte compilation uses this feature. -@smallexample +@example @group (defmacro inc (var) (list 'setq var (list '1+ var))) @@ -132,7 +132,7 @@ uses this feature. (macroexpand '(inc2 r s)) @result{} (progn (inc r) (inc s)) ; @r{@code{inc} not expanded here.} @end group -@end smallexample +@end example @end defun @@ -146,10 +146,10 @@ Repeating the example used for @code{macroexpand} above with @code{macroexpand-all}, we see that @code{macroexpand-all} @emph{does} expand the embedded calls to @code{inc}: -@smallexample +@example (macroexpand-all '(inc2 r s)) @result{} (progn (setq r (1+ r)) (setq s (1+ s))) -@end smallexample +@end example @end defun @@ -333,7 +333,7 @@ following macro (used to facilitate iteration) illustrates the problem. This macro allows us to write a ``for'' loop construct. @findex for -@smallexample +@example @group (defmacro for (var from init to final do &rest body) "Execute a simple \"for\" loop. @@ -364,7 +364,7 @@ For example, (for i from 1 to 10 do (print i))." @print{}3 9 @result{} nil @end group -@end smallexample +@end example @noindent The arguments @code{from}, @code{to}, and @code{do} in this macro are @@ -374,7 +374,7 @@ in those positions in the macro call. Here's an equivalent definition simplified through use of backquote: -@smallexample +@example @group (defmacro for (var from init to final do &rest body) "Execute a simple \"for\" loop. @@ -384,7 +384,7 @@ For example, (for i from 1 to 10 do (print i))." ,@@body (inc ,var)))) @end group -@end smallexample +@end example Both forms of this definition (with backquote and without) suffer from the defect that @var{final} is evaluated on every iteration. If @@ -399,7 +399,7 @@ producing an expansion that evaluates the argument expressions exactly once unless repeated evaluation is part of the intended purpose of the macro. Here is a correct expansion for the @code{for} macro: -@smallexample +@example @group (let ((i 1) (max 3)) @@ -408,11 +408,11 @@ macro. Here is a correct expansion for the @code{for} macro: (princ (format "%d %d" i square)) (inc i))) @end group -@end smallexample +@end example Here is a macro definition that creates this expansion: -@smallexample +@example @group (defmacro for (var from init to final do &rest body) "Execute a simple for loop: (for i from 1 to 10 do (print i))." @@ -422,7 +422,7 @@ Here is a macro definition that creates this expansion: ,@@body (inc ,var)))) @end group -@end smallexample +@end example Unfortunately, this fix introduces another problem, described in the following section. @@ -435,7 +435,7 @@ described in the following section. follows to make the expansion evaluate the macro arguments the proper number of times: -@smallexample +@example @group (defmacro for (var from init to final do &rest body) "Execute a simple for loop: (for i from 1 to 10 do (print i))." @@ -447,14 +447,14 @@ number of times: ,@@body (inc ,var)))) @end group -@end smallexample +@end example @end ifnottex The new definition of @code{for} has a new problem: it introduces a local variable named @code{max} which the user does not expect. This causes trouble in examples such as the following: -@smallexample +@example @group (let ((max 0)) (for x from 0 to 10 do @@ -462,7 +462,7 @@ causes trouble in examples such as the following: (if (< max this) (setq max this))))) @end group -@end smallexample +@end example @noindent The references to @code{max} inside the body of the @code{for}, which @@ -478,7 +478,7 @@ put it into the program later. It will never appear anywhere except where put by @code{for}. Here is a definition of @code{for} that works this way: -@smallexample +@example @group (defmacro for (var from init to final do &rest body) "Execute a simple for loop: (for i from 1 to 10 do (print i))." @@ -489,7 +489,7 @@ this way: ,@@body (inc ,var))))) @end group -@end smallexample +@end example @noindent This creates an uninterned symbol named @code{max} and puts it in the |