unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
	52147@debbugs.gnu.org, Paul Pogonyshev <pogonyshev@gmail.com>
Subject: bug#52147: Eager macro-expansion is not performed in `eval-and-compile' functions
Date: Sat, 15 Jan 2022 10:09:36 -0500	[thread overview]
Message-ID: <jwv35lpkq0k.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87pmotta9j.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 15 Jan 2022 14:10:32 +0100")

>>> We usually don't stress a lot about the performance of interpreted
>>> (i.e., uncompiled) code.

Indeed.

>> Well we do, a bit,
>>
>>   (info "(elisp) How Programs Do Loading")
>>
>> says that loading a file performs eager macro expansion and that does
>> speed up the resulting code.  `eval', `eval-when-compile' and
>> `eval-and-compile' don't perform eager macro expansion.  I don't know to
>> what degree this is on purpose.  But if a macro is defined later in the
>> file or in another file that has not yet been loaded this may not be
>> possible anyway.
>
> It sounds to me like things are basically working as designed.
>
> Perhaps Stefan has some comments; added to the CCs.

AFAIK the exact time of macro expansion is left underspecified
on purpose.  Whether eager-macroexpansion is used or not should be an
implementation detail.  A piece of code which relies on macro-expansion
being done lazily is a bug, AFAIC.  Usually those bugs become apparent
when byte-compiling the file (where macro-expansion is necessarily
eager), except for those cases that occur during bootstrap.

Both `eval-when-compile` and `eval-and-compile` currently defer to
`eval`, but they should arguably do the macro-expansion eagerly, indeed.

`eval` currently doesn't use eager macro-expansion because I haven't
done the work needed to check/ensure that the resulting potential
slowdown is negligible.  But I think `eval` should also eagerly
macro-expand its argument.


        Stefan






  reply	other threads:[~2022-01-15 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 19:37 bug#52147: Eager macro-expansion is not performed in `eval-and-compile' functions Paul Pogonyshev
2021-11-28 10:30 ` Michael Heerdegen
2021-11-28 21:53   ` Paul Pogonyshev
2021-11-29 15:44     ` Lars Ingebrigtsen
2021-11-29 19:14       ` Michael Heerdegen
2022-01-15 13:10         ` Lars Ingebrigtsen
2022-01-15 15:09           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-20  9:50             ` Lars Ingebrigtsen

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=jwv35lpkq0k.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=52147@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=pogonyshev@gmail.com \
    /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).