diff options
| author | Štěpán Němec | 2021-04-24 21:19:48 +0200 |
|---|---|---|
| committer | Štěpán Němec | 2021-04-25 09:30:16 +0200 |
| commit | bda866009b48b73053d479ffb88e7a7ffbcf7996 (patch) | |
| tree | fd250bc58408ab904a61183adb2e2eec6328b426 | |
| parent | 86d1b4d88f2999d2b0f94619dc53092bddfa0ec0 (diff) | |
| download | emacs-bda866009b48b73053d479ffb88e7a7ffbcf7996.tar.gz emacs-bda866009b48b73053d479ffb88e7a7ffbcf7996.zip | |
* doc/lispref/macros.texi (Eval During Expansion): Copy edit.
| -rw-r--r-- | doc/lispref/macros.texi | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/doc/lispref/macros.texi b/doc/lispref/macros.texi index 7c090aebc86..b8df363614d 100644 --- a/doc/lispref/macros.texi +++ b/doc/lispref/macros.texi | |||
| @@ -480,15 +480,17 @@ in expressions ordinarily. | |||
| 480 | 480 | ||
| 481 | Another problem can happen if the macro definition itself | 481 | Another problem can happen if the macro definition itself |
| 482 | evaluates any of the macro argument expressions, such as by calling | 482 | evaluates any of the macro argument expressions, such as by calling |
| 483 | @code{eval} (@pxref{Eval}). You have to take into account that the | 483 | @code{eval} (@pxref{Eval}). You have to take into account that macro |
| 484 | context of the caller is not accessible at that time since the macro expansion | 484 | expansion may take place long before the code is executed, when the |
| 485 | may take place long before the code is executed. Also if your macro definition | 485 | context of the caller (where the macro expansion will be evaluated) is |
| 486 | does not use @code{lexical-binding} its own variables may hide the | 486 | not yet accessible. |
| 487 | user's variables, if the user happens to use a | 487 | |
| 488 | variable with the same name as one of the macro arguments. Inside the | 488 | Also, if your macro definition does not use @code{lexical-binding}, its |
| 489 | macro body, the macro argument binding is the most local binding of this | 489 | formal arguments may hide the user's variables of the same name. Inside |
| 490 | variable, so any references inside the form being evaluated do refer to | 490 | the macro body, the macro argument binding is the most local binding of |
| 491 | it. Here is an example: | 491 | such variable, so any references inside the form being evaluated do refer |
| 492 | to it. Here is an example: | ||
| 493 | |||
| 492 | @example | 494 | @example |
| 493 | @group | 495 | @group |
| 494 | (defmacro foo (a) | 496 | (defmacro foo (a) |
| @@ -510,9 +512,9 @@ it. Here is an example: | |||
| 510 | @code{x}, because @code{a} conflicts with the macro argument variable | 512 | @code{x}, because @code{a} conflicts with the macro argument variable |
| 511 | @code{a}. | 513 | @code{a}. |
| 512 | 514 | ||
| 513 | Also the expansion of @code{(foo x)} above will return something | 515 | Also, the expansion of @code{(foo x)} above will return something |
| 514 | different or signal an error when the code is compiled since in that case | 516 | different or signal an error when the code is compiled, since in that case |
| 515 | @code{(foo x)} is expanded during compilation whereas the execution of | 517 | @code{(foo x)} is expanded during compilation, whereas the execution of |
| 516 | @code{(setq x 'b)} will only take place later when the code is executed. | 518 | @code{(setq x 'b)} will only take place later when the code is executed. |
| 517 | 519 | ||
| 518 | To avoid these problems, @strong{don't evaluate an argument expression | 520 | To avoid these problems, @strong{don't evaluate an argument expression |