unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: "Omar Antolín Camarena" <omar@matem.unam.mx>
Cc: 40827@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Sat, 25 Apr 2020 10:49:03 -0400	[thread overview]
Message-ID: <87sggrfwo0.fsf@gmail.com> (raw)
In-Reply-To: <874kt8snsq.fsf@matem.unam.mx> ("Omar Antolín Camarena"'s message of "Fri, 24 Apr 2020 14:09:57 -0500")

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.





  reply	other threads:[~2020-04-25 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 19:09 bug#40827: 28.0.50; Macroexpansion at runtime Omar Antolín Camarena
2020-04-25 14:49 ` Noam Postavsky [this message]
2020-04-25 20:04   ` Stefan Monnier
2021-08-10 16:05     ` Lars Ingebrigtsen
2020-04-26  3:28   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sggrfwo0.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=40827@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=omar@matem.unam.mx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).