help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macro Expansion Inconsistency


From: Barry Margolin
Subject: Re: Macro Expansion Inconsistency
Date: Wed, 17 Dec 2014 10:53:48 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.16290.1418825041.1147.help-gnu-emacs@gnu.org>,
 Alexander Shukaev <haroogan@gmail.com> wrote:

> Thank you very much, John and Nicolas. I think I finally understand how
> macros expand in Emacs Lisp better now. I'm sure it's not a coincidence
> that you both came up with almost identical solutions. It suggests that the
> style of returning forms for evaluation from macro is probably the best way
> to go in most cases when `let' is involved.

Not just "probably the best" -- this is the ONLY way to go in macros. 
The whole point of macros is to produce new code to be evaluated in 
place of the original code.

The important thing to remember about macros is that they run when 
you're COMPILING the code, not when you run it. These may be 
approximately the same time if you evaluate the calling code (e.g. by 
typing it into the *scratch* buffer, loading the source file, M-x 
eval-region). This is why calling eval seems to work when you're testing 
the macro interactively.

But if you byte-compile the file, it will be run then, not when you 
later load the .elc file. This will usually be a totally different Emacs 
session, so it should be obvious why the results of calling eval won't 
be available then.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]