From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 65051@debbugs.gnu.org
Subject: bug#65051: internal_equal manipulates symbols with position without checking symbols-with-pos-enabled.
Date: Thu, 10 Aug 2023 18:35:27 +0000 [thread overview]
Message-ID: <ZNUt7-mqF_admTg5@ACM> (raw)
In-Reply-To: <jwvedkbui8u.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Thu, Aug 10, 2023 at 10:28:55 -0400, Stefan Monnier wrote:
[ .... ]
> >> > In the code at the moment, the result of `equal' on symbols with
> >> > position is undefined, i.e. it returns a random value.
> >> In which sense?
> > In the sense it wasn't deliberately coded. It's just a random value
> > resulting from the code for other scenarios.
> Then it's not "random" nor "undefined".
> I'd describe it as "arbitrary".
Then we're reduced to arguing about words rather than Emacs.
> >> AFAICT it returns non-nil iff the underlying bare symbols are `eq`.
> >> That does not sound "random" at all to me.
> >> What am I missing?
> > That equal is different from eq.
> Then let me rephrase the above:
> AFAICT it returns non-nil iff the underlying bare symbols are `equal`.
> See? No` eq` any more :-)
Yes I see, and it is wrong.
Let me try another tack. Look closely at the definition of
symbols-with-pos-enabled:
(i) When nil: Emacs works without any special handling for SWPs.
(ii) When non-nil: Emacs handles SWPs as though they were their bare
symbols.
> > The definition of eq (more or less) is "identical objects".
> > The definition of equal (more or less) is "same structure with same
> > components".
> Yes, but the "more or less" is very applicable to SWP.
> E.g. one could argue that if two objects are sometimes `eq`, then
> I think it's a good enough justification to treat them as always
> `equal`.
A SWP is sometimes EQ its bare symbol, in particular when
symbols-with-pos-enabled is non-nil. That is no justification for
regarding the two as _always_ EQ, in particular when s-w-p-enabled is
nil. If you were to make that argument, you would be arguing for a
significant slowdown in Emacs.
> > See my previous paragraph of this post. You're proposing that the
> > position elements of SWPs should be ignored in equal. I don't see any
> > good reason for this.
> One reason is that it's the semantics we use 99% of the time (where
> `symbols-with-pos-enabled` is also non-nil).
It's not the semantics we should use when s-w-p-enabled is nil. That
would violate the definition of symbols-with-pos-enabled. See above.
> But as I said at the beginning, my main point is that the current
> behavior is not a *bug*. It's just an arbitrary semantics, and you're
> proposing to use another arbitrary semantics.
I'm proposing correctness, according to a coherent definition of
symbols-with-pos-enabled. I was surprised indeed, and continue to be
surprised, that you do not see this correction as a correction. To me,
it's obvious.
> And the new arbitrary semantics does not seem clearly superior.
> IOW, bikeshedding material.
The correctness of symbols-with-pos-enabled is not arbitrary.
If you think the semantics are arbitrary, why are you so fixed on
implementing a particular one of them?
[ .... ]
> But the behavior for `equal` is not "special" IMO. It fits within the
> general behavior of `equal`.
Yet you're insisting on special behaviour for SWP's when
symbols-with-pos-enabled is nil.
[ .... ]
> None of it is concrete, and I disagree with them, so it's just my opinion
> against your opinion. We're not going to have much success with that.
> Hence the need for more concrete practical arguments.
Well, one argument, not very strong but stronger than any other you'll
accept is that the code and documentation amendments have already been
made. There are so far no signs of the needed documentation changes for
leaving the handling of SWPs by equal contrasting with that of other
types.
> >> > It was me that coded up that amendment to equal, and I can remember
> >> > simply not taking into account the scenario we're talking about.
> >> Which scenario?
> > <sigh> Comparing two arguments using equal, at least one of which is a
> > symbol with position, when symbols-with-pos-enabled is nil.
> Ah, sorry, I thought you were referring to a more concrete use-case
> where such a `equal` test would occur. Having such use-cases would help
> the current discussion significantly, since currently we're basically
> arguing about what Emacs should do in cases that never occur.
That is the case, yes. There are no current use-cases for SWPs with
s-w-p-enabled nil.
[ .... ]
> > So why are you making such a big thing out of it?
> [ Hmm... I have a feeling of déjà-vu. ]
> > I see quite clearly which of these options is correct.
> > Why won't you respect my superior insight into the matter?
> [ Hmm... this sounds a bit arrogant, so I'll just skip it. ]
No, you won't. There is a basic contradiction in your stance, namely
you say on the one hand that the correct strategy here is arbitrary, yet
on the other hand that the one you prefer is overwhelmingly better. If
you were being honest about this arbitrariness, you wouldn't be making
such a song and dance about it.
> >> It makes it impure, and will invalidate existing optimizations,
> >> exactly like we've just witnessed for `eq`.
> > Which optimisations are you talking about here? Just how is equal
> > optimised?
> The same one that causes my bug-fix to fail:
> (let ((symbols-with-position-enabled V)) (equal E1 E2))
> is optimized to
> (equal E1 E2)
What can I say? If you eliminate semantically essential code what you
end up with is not what you started with. Is there actually an instance
of the above code in the Emacs sources? In particular, one where
symbols-with-position-enabled gets bound by a let, and the body of the
let contains an equal (or member, or ...), but no uses of EQ?
> -- Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2023-08-10 18:35 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 14:00 bug#65051: internal_equal manipulates symbols with position without checking symbols-with-pos-enabled Alan Mackenzie
2023-08-04 14:32 ` Eli Zaretskii
2023-08-04 14:59 ` Alan Mackenzie
2023-08-04 15:27 ` Eli Zaretskii
2023-08-04 17:06 ` Alan Mackenzie
2023-08-04 18:01 ` Eli Zaretskii
2023-08-05 10:45 ` Alan Mackenzie
2023-08-05 10:57 ` Eli Zaretskii
2023-08-05 11:52 ` Alan Mackenzie
2023-08-05 12:13 ` Eli Zaretskii
2023-08-05 13:04 ` Alan Mackenzie
2023-08-05 13:13 ` Eli Zaretskii
2023-08-13 16:14 ` Alan Mackenzie
2023-08-05 14:40 ` Mattias Engdegård
2023-08-05 16:59 ` Alan Mackenzie
2023-08-05 17:02 ` Mattias Engdegård
2023-08-05 21:07 ` Alan Mackenzie
2023-08-06 13:37 ` Mattias Engdegård
2023-08-06 15:02 ` Alan Mackenzie
2023-08-07 8:58 ` Mattias Engdegård
2023-08-07 9:44 ` Alan Mackenzie
2023-08-09 18:45 ` Mattias Engdegård
2023-08-07 3:30 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-07 9:20 ` Alan Mackenzie
2023-08-08 2:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-08 15:33 ` Alan Mackenzie
2023-08-10 3:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-10 9:14 ` Alan Mackenzie
2023-08-10 14:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-10 18:35 ` Alan Mackenzie [this message]
2023-08-12 5:36 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-12 6:10 ` Eli Zaretskii
2023-08-12 18:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-12 19:10 ` Eli Zaretskii
2023-08-13 15:27 ` Alan Mackenzie
2023-08-12 10:41 ` Alan Mackenzie
2023-08-12 18:07 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-13 13:52 ` Alan Mackenzie
2023-08-12 21:59 ` Alan Mackenzie
2023-08-11 0:51 ` Dmitry Gutov
2023-08-11 10:42 ` Alan Mackenzie
2023-08-11 11:18 ` Dmitry Gutov
2023-08-11 12:05 ` Alan Mackenzie
2023-08-11 13:19 ` Dmitry Gutov
2023-08-11 14:04 ` Alan Mackenzie
2023-08-11 18:15 ` Dmitry Gutov
[not found] ` <handler.65051.B.169115764532326.ack@debbugs.gnu.org>
2023-09-04 12:57 ` bug#65051: Acknowledgement (internal_equal manipulates symbols with position without checking symbols-with-pos-enabled.) 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
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=ZNUt7-mqF_admTg5@ACM \
--to=acm@muc.de \
--cc=65051@debbugs.gnu.org \
--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 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).