From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: "Mattias Engdegård" <mattias.engdegard@gmail.com>,
65017@debbugs.gnu.org,
"Eric Marsden" <eric.marsden@risk-engineering.org>
Subject: bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function
Date: Fri, 11 Aug 2023 23:28:01 -0400 [thread overview]
Message-ID: <jwv350pugvs.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <ZNT5G7-aPp5t9vbe@ACM> (Alan Mackenzie's message of "Thu, 10 Aug 2023 14:50:03 +0000")
>> > And if, somehow, it does get used (the current code, I think), then (as
>> > you write below) the argument F will get replaced by an F with the wrong
>> > position. Am I right, here?
>> That's right.
> OK. So perhaps binding symbols-with-pos-enabled to nil around that eq
> call could be the way to go.
Indeed, that's the patch I suggested. I think it's fundamentally right,
but it doesn't work (yet) because it bumps into the optimization bug
introduced by making `eq` depend on `symbols-with-pos-enabled` :-(
>> > Why must the F get replaced by a different F? There must surely be a
>> > way, a simpler way than the current cl--labels-convert, to retain the
>> > current F (hence, not corrupting its position)?
>> There might. The current hack is the best I could come up with.
> I'm not criticising the hack, not at all! But it could be better
> commented, and the doc string for cl--labels-convert could be more
> informative.
It would help if you could send a (rough) patch showing what comment
you'd have liked to see.
> The "why" is missing - why is necessary to handle `function' as
> a macro?
I couldn't really think of any alternative for it ("it" being to
implement `cl-labels` and `cl-flet`). FWIW, the pre-cl-lib code did it
differently by duplicating `macroexp--expand-all` wholesale and then
tweaking its handling of `function` in an ad-hoc way.
BTW, there's a standard solution from Common Lisp to get rid of this
hack: implement the `&whole` macro argument.
[Macro Lambda Lists](http://clhs.lisp.se/Body/03_dd.htm)
> I think it's to inhibit the processing of `function' as function
> somewhere else, but where and why?
It's not a function but a special operator, which is thus handled in
a hard-coded way by `macroexp--expand-all`.
>> I'm not completely sure we agree yet on what is "the original bug", but
>> obviously I agree with your sentence :-)
> I meant bug #65017. I committed a fix for it yesterday using the patch
> I posted here on Sunday, and closed the bug.
FWIW my notion of "the original bug" should be fixed by the patch below
(modulo the above-mentioned optimization bug which makes the patch
ineffective).
BTW, I pushed an extended version of that patch which additionally does
what you suggested we should do (and which I claimed wouldn't work),
i.e. flush the cache (I originally couldn't see where to flush it).
I believe this does fix the original problem even in the remaining
corner cases, despite the optimization bug.
Stefan
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 0a3181561bd..a405ae67691 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2037,7 +2037,9 @@ cl--labels-convert
;; *after* handling `function', but we want to stop macroexpansion from
;; being applied infinitely, so we use a cache to return the exact `form'
;; being expanded even though we don't receive it.
- ((eq f (car cl--labels-convert-cache)) (cdr cl--labels-convert-cache))
+ ((let ((symbols-with-pos-enabled nil))
+ (eq f (car cl--labels-convert-cache)))
+ (cdr cl--labels-convert-cache))
(t
(let* ((found (assq f macroexpand-all-environment))
(replacement (and found
next prev parent reply other threads:[~2023-08-12 3:28 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 10:28 bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function Eric Marsden
2023-08-03 9:39 ` Mattias Engdegård
2023-08-03 14:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 15:37 ` Mattias Engdegård
2023-08-03 16:36 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 16:53 ` Mattias Engdegård
2023-08-03 17:30 ` Mattias Engdegård
2023-08-03 16:43 ` Alan Mackenzie
2023-08-03 17:30 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 18:22 ` Alan Mackenzie
2023-08-03 21:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 21:10 ` Alan Mackenzie
2023-08-03 21:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 9:55 ` Alan Mackenzie
2023-08-05 22:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 10:14 ` Mattias Engdegård
2023-08-04 11:11 ` Alan Mackenzie
2023-08-04 13:41 ` Mattias Engdegård
2023-08-05 22:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-06 10:47 ` Mattias Engdegård
2023-08-08 2:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 5:35 ` Eli Zaretskii
2023-08-04 14:16 ` Alan Mackenzie
2023-08-05 20:22 ` Alan Mackenzie
2023-08-06 4:49 ` Eli Zaretskii
2023-08-04 13:22 ` Alan Mackenzie
2023-08-04 14:04 ` Eli Zaretskii
2023-08-04 14:49 ` Alan Mackenzie
2023-08-04 15:22 ` Eli Zaretskii
2023-08-04 16:43 ` Alan Mackenzie
2023-08-04 17:54 ` Eli Zaretskii
2023-08-05 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-05 22:53 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-06 11:59 ` Alan Mackenzie
2023-08-08 2:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-08 16:56 ` Alan Mackenzie
2023-08-10 3:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-10 14:50 ` Alan Mackenzie
2023-08-12 3:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-12 9:59 ` Mattias Engdegård
2023-08-12 18:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-12 10:40 ` Mattias Engdegård
2023-08-12 16:46 ` Alan Mackenzie
2023-08-12 18:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-13 10:10 ` Alan Mackenzie
2023-08-13 16:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-14 17:10 ` Alan Mackenzie
2023-08-03 16:11 ` Alan Mackenzie
2023-08-03 16:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 18:48 ` Alan Mackenzie
2023-08-09 12:27 ` 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=jwv350pugvs.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=65017@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=eric.marsden@risk-engineering.org \
--cc=mattias.engdegard@gmail.com \
--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.