summaryrefslogtreecommitdiff
path: root/devdocs/elisp/wrong-time.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/wrong-time.html
new repository
Diffstat (limited to 'devdocs/elisp/wrong-time.html')
-rw-r--r--devdocs/elisp/wrong-time.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/elisp/wrong-time.html b/devdocs/elisp/wrong-time.html
new file mode 100644
index 00000000..af78f3a1
--- /dev/null
+++ b/devdocs/elisp/wrong-time.html
@@ -0,0 +1,14 @@
+ <h4 class="subsection">Wrong Time</h4> <p>The most common problem in writing macros is doing some of the real work prematurely—while expanding the macro, rather than in the expansion itself. For instance, one real package had this macro definition: </p> <div class="example"> <pre class="example">(defmacro my-set-buffer-multibyte (arg)
+ (if (fboundp 'set-buffer-multibyte)
+ (set-buffer-multibyte arg)))
+</pre>
+</div> <p>With this erroneous macro definition, the program worked fine when interpreted but failed when compiled. This macro definition called <code>set-buffer-multibyte</code> during compilation, which was wrong, and then did nothing when the compiled package was run. The definition that the programmer really wanted was this: </p> <div class="example"> <pre class="example">(defmacro my-set-buffer-multibyte (arg)
+ (if (fboundp 'set-buffer-multibyte)
+ `(set-buffer-multibyte ,arg)))
+</pre>
+</div> <p>This macro expands, if appropriate, into a call to <code>set-buffer-multibyte</code> that will be executed when the compiled program is actually run. </p><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/Wrong-Time.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Wrong-Time.html</a>
+ </p>
+</div>