summaryrefslogtreecommitdiff
path: root/devdocs/elisp/problems-with-macros.html
blob: 5667b4062e4508169dfaedf00ff826df6db418c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 <h3 class="section">Common Problems Using Macros</h3>  <p>Macro expansion can have counterintuitive consequences. This section describes some important consequences that can lead to trouble, and rules to follow to avoid trouble. </p> <table class="menu" border="0" cellspacing="0"> <tr>
<td align="left" valign="top">• <a href="wrong-time" accesskey="1">Wrong Time</a>
</td>
<td> </td>
<td align="left" valign="top">Do the work in the expansion, not in the macro. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="argument-evaluation" accesskey="2">Argument Evaluation</a>
</td>
<td> </td>
<td align="left" valign="top">The expansion should evaluate each macro arg once. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="surprising-local-vars" accesskey="3">Surprising Local Vars</a>
</td>
<td> </td>
<td align="left" valign="top">Local variable bindings in the expansion require special care. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="eval-during-expansion" accesskey="4">Eval During Expansion</a>
</td>
<td> </td>
<td align="left" valign="top">Don’t evaluate them; put them in the expansion. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="repeated-expansion" accesskey="5">Repeated Expansion</a>
</td>
<td> </td>
<td align="left" valign="top">Avoid depending on how many times expansion is done. </td>
</tr> </table><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/Problems-with-Macros.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Problems-with-Macros.html</a>
  </p>
</div>