GNU Info

Info Node: (elisp)Wrong Time

(elisp)Wrong Time


Next: Argument Evaluation Up: Problems with Macros
Enter node , (file) or (file)node

Wrong Time
----------

   The most common problem in writing macros is doing too some of the
real work prematurely--while expanding the macro, rather than in the
expansion itself.  For instance, one real package had this nmacro
definition:

     (defmacro my-set-buffer-multibyte (arg)
       (if (fboundp 'set-buffer-multibyte)
           (set-buffer-multibyte arg)))

   With this erroneous macro definition, the program worked fine when
interpreted but failed when compiled.  This macro definition called
`set-buffer-multibyte' during compilation, which was wrong, and then
did nothing when the compiled package was run.  The definition that the
programmer really wanted was this:

     (defmacro my-set-buffer-multibyte (arg)
       (if (fboundp 'set-buffer-multibyte)
           `(set-buffer-multibyte ,arg)))

This macro expands, if appropriate, into a call to
`set-buffer-multibyte' that will be executed when the compiled program
is actually run.


automatically generated by info2www version 1.2.2.9