GNU bug report logs - #40827
28.0.50; Macroexpansion at runtime

Previous Next

Package: emacs;

Reported by: Omar Antolín Camarena <omar <at> matem.unam.mx>

Date: Fri, 24 Apr 2020 19:11:02 UTC

Severity: normal

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 40827 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Omar Antolín Camarena <omar <at> matem.unam.mx>
Cc: 40827 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Sat, 25 Apr 2020 10:49:03 -0400
Omar Antolín Camarena <omar <at> 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.




This bug report was last modified 3 years and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.