From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
Lars Ingebrigtsen <larsi@gnus.org>,
54079@debbugs.gnu.org
Subject: bug#54079: 29.0.50; Method dispatching eratically fails
Date: Wed, 9 Mar 2022 17:42:56 +0000 [thread overview]
Message-ID: <YijnIA12P7xs8dlV@ACM> (raw)
In-Reply-To: <jwvv8wof9l9.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Tue, Mar 08, 2022 at 16:03:12 -0500, Stefan Monnier wrote:
> >> I'd expect the reverse: strip first and then eval the result.
> >> Why should we not strip the form passed to `byte-compile-eval`?
> > It's an edge case either way, but the form being evaluated might be a
> > `byte-compile', in which case it's (much) better to leave the positions
> > in place during this operation.
> I don't understand the scenario you're thinking of.
> Are you thinking of something like `(eval-when-compile (byte-compile ...))?
Yes.
> Does that ever happen in real life?
Probably exceedingly seldomly.
What's to be gained by not catering to this unusual case? What do we
lose?
> >> Does `byte-compile-top-level` already return a stripped form of code?
> > Compiled code is always stripped, at least since the weekend!
> OK, so no need to strip, go.
> >> And why bother stripping the result of `byte-compile-eval`?
> > Because it might be the result of evaluating a defun (or defvar or
> > defconst).
> AFAIK sympos should only appear within the compiler pipeline between the
> "read" and the "emit resulting bytecode". They may be passed to various
> functions and macros along the way, but I can't think of any scenario
> where they'd end up returned by `(byte-compile-)eval`.
> > This was the situation which gave rise to the bug.
> Could you give some details about how it played out?
> [ Either here or as a comment in the code. ]
Michael byte compiled cl-generic.el. This created cl-generic.elc
correctly, but also left uncompiled forms in the function cells of the
symbols defun'd inside an eval-{when,and}-compile. These forms
contained symbols with positions.
> >> Fundamentally, `eval` should always strip before doing its job.
> > Except when what it's evaluating is a defun, defmacrro, defsubst, etc.
> Why?
Because that evaluated form might later be byte compiled, and the SWPs
will be needed for that.
> > Then it would be better to evaluate SWPs (which would work, since we're
> > inside a compilation, where enable-symbols-with-pos has been bound).
> > But here EXPANDED has been stripped before being evaluated, so I'm not
> > sure what you're saying here.
> I was suggesting to move the strip from the computation of `expanded` to
> the `eval` call.
> >> Yes, I know, it might be a bit expensive, but we should probably
> >> define a local function in `bytecomp.el` which does strip+eval and use
> >> that instead of `eval` (both here and in `byte-compile-eval`). WDYT?
> > I don't think stripping is really all that expensive. There are one or
> > two .el files in Emacs (ucs-normalize.el springs to mind) which have
> > very large lists with vectors in them, yet they don't seem noticeably to
> > slow down the Emacs build.
> So maybe we should redefine `eval` as "strip and then eval"?
Isn't `eval' already complicated enough, with lexical-binding as an
argument? Stripping SWPs is not a part of evaluation. It is something
else. eval should "do one thing and do it well".
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2022-03-09 17:42 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 0:12 bug#54079: 29.0.50; Method dispatching eratically fails Michael Heerdegen
2022-02-21 1:14 ` Michael Heerdegen
2022-03-04 16:12 ` Lars Ingebrigtsen
2022-02-21 3:16 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 4:21 ` Michael Heerdegen
2022-02-22 23:55 ` Michael Heerdegen
2022-02-23 0:27 ` Michael Heerdegen
2022-02-23 0:47 ` Michael Heerdegen
2022-03-04 2:08 ` Michael Heerdegen
2022-03-04 19:11 ` Alan Mackenzie
2022-03-05 16:37 ` Alan Mackenzie
2022-03-05 17:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-05 19:00 ` Alan Mackenzie
2022-03-05 23:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-05 18:19 ` Eli Zaretskii
2022-03-05 19:07 ` Alan Mackenzie
2022-03-06 2:19 ` Michael Heerdegen
2022-03-08 19:28 ` Alan Mackenzie
2022-03-08 19:53 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-08 20:48 ` Alan Mackenzie
2022-03-08 21:03 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-09 17:42 ` Alan Mackenzie [this message]
2022-03-09 18:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-09 20:32 ` Alan Mackenzie
2022-03-09 22:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-11 22:01 ` Alan Mackenzie
2022-03-12 4:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-13 16:49 ` Alan Mackenzie
2022-03-14 12:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-09 4:10 ` Michael Heerdegen
2022-03-09 17:29 ` Alan Mackenzie
2022-03-16 1:44 ` Michael Heerdegen
2022-03-16 11:52 ` Alan Mackenzie
2022-03-16 19:22 ` Michael Heerdegen
2022-03-17 2:58 ` Michael Heerdegen
2022-03-16 19:29 ` Alan Mackenzie
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YijnIA12P7xs8dlV@ACM \
--to=acm@muc.de \
--cc=54079@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=michael_heerdegen@web.de \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.