[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40827: 28.0.50; Macroexpansion at runtime
From: |
Noam Postavsky |
Subject: |
bug#40827: 28.0.50; Macroexpansion at runtime |
Date: |
Sat, 25 Apr 2020 10:49:03 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) |
Omar Antolín Camarena <omar@matem.unam.mx> writes:
> It seems that now, most of the time both the intepreter and the
> byte-compiler, whether using lexical binding or not, will expand macros
> at function definition time. This trick of combining an illegal (rx ...
> (eval ...) ...), with lexical binding, and with eval-defun is the only
> way I've found to trigger macro expansion at runtime.
[...]
> I discovered this during an interesting discussion on reddit, which you
> can read here:
>
> https://www.reddit.com/r/emacs/comments/g5bat3/weekly_tipstricketc_thread/fo362s8
[...]
> (info "(elisp) Repeated Expansion") says:
>
>> 14.5.5 How Many Times is the Macro Expanded?
>
>> Occasionally problems result from the fact that a macro call is
>> expanded each time it is evaluated in an interpreted function, but is
>> expanded only once (during compilation) for a compiled function. If
>> the macro definition has side effects, they will work differently
>> depending on how many times the macro is expanded.
Also further down:
[...] But in interpreted execution, the macro is expanded each
time the macro call runs
[...]
If `initialize' is interpreted, a new list `(nil)' is constructed each
time `initialize' is called.
(elisp "(elisp) Expansion") does mention that uncompiled macro calls
(usually) also get expanded just once:
Note that Emacs tries to expand macros when loading an uncompiled
Lisp file. This is not always possible, but if it is, it speeds up
subsequent execution. *Note How Programs Do Loading::.
Ccing Stefan M, since you made the eager macroexpansion changes as far
as I recall.