Subject: Re: bug#65051: internal_equal manipulates symbols with position without checking symbols-with-pos-enabled.

From: Alan Mackenzie <[email-masked]>
Date: Tue, 8 Aug 2023 15:33:32 +0000

Hello, Stefan.

On Mon, Aug 07, 2023 at 22:56:31 -0400, Stefan Monnier wrote:
> >> Could you explain why you think it's a bug?
> > When symbols-with-pos-enabled is non-nil, the two arguments to that
> > equal call are equal.  That is the point of s-w-p-e.

> AFAIK the point of the `symbols-with-pos-enabled` is to try and keep the
> performance impact of sympos under control, and that matters only for
> `eq`, so I don't think there's a strong reason here for `equal` to pay
> attention to it.

Which is like saying you're happy for it to be undefined.  In the code
at the moment, the result of `equal' on symbols with position is
undefined, i.e. it returns a random value.

> > When s-w-p-e is nil, and the "magic" is thus switched off, the two lisp
> > objects have different type (the first is a symbol, the second is a
> > pseudovector), thus cannot be equal.

> "cannot" is obviously not the correct word here, since currently they
> are considered `equal`, so clearly they *can* be considered `equal`:
> it's easy to implement, and experience shows that "it works".

> So I'm still wondering why you think it's a bug.

Because it violates the definition and basic understanding of equal.
It's a special case when no special case is needed.

> AFAICT whether sympos should be `equal` to others and/or to bare symbols
> is something we pretty much get to choose freely based on convenience:

No we don't.  They have to be chosen to be as consistent as possible
with the rest of Emacs.

> either the current behavior or the one you now advocate are perfectly
> acceptable and not bugs.

The current behaviour is a bug.  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.

> As I said elsewhere, I'm not sure which choice is best, but at least we
> have some experience with the current choice ....

I rather doubt that.  When have SWPs, when symbols-with-pos-enabled is
nil, been tested by equal, apart from in tests, maybe?

> .... and I haven't seen any clear problem with it yet, so I'd tend to
> lean towards keeping the current behavior.

I'm wondering why you're making such a big thing out of it.  It's a
small change which will increase consistency and predictability in
Emacs in a small way, without any negative effects.

> What would be the concrete advantages of the new behavior compared to
> the current one?

There are no "concrete" advantages, aside from an insignificant increase
in speed for Emacs when not byte compiling.  The code and the
documentation currently don't match.  Fixing the code, by removing a
special case, is easier and more satisfying than documenting that
special case in the Elisp manual.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).