GNU bug report logs - #48281
buffer_local_value and find_symbol_value duplicate functionality

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> catern.com>

Date: Fri, 7 May 2021 22:45:02 UTC

Severity: normal

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48281 in the body.
You can then email your comments to 48281 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48281; Package emacs. (Fri, 07 May 2021 22:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Spencer Baugh <sbaugh <at> catern.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 07 May 2021 22:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> catern.com>
To: bug-gnu-emacs <at> gnu.org
Subject: buffer_local_value and find_symbol_value duplicate functionality
Date: Fri, 07 May 2021 18:44:33 -0400
find_symbol_value is described as:

  Find the value of a symbol, returning Qunbound if it's not bound.

buffer_local_value does the same, except that it allows one to specify a
buffer.

Yet they both implement symbol lookup, without sharing code.  And given
that the comment above find_symbol_value says "Great care is required
for this.", I'm guessing that one or both of them may have bugs that the
other does not.  Especially because buffer_local_value is simpler than
find_symbol_value, despite doing an ostensibly more complicated job...

How about unifying them into a single function?  Would a patch doing
that be accepted?

Alternatively, maybe I'm missing some detail about why they're
different?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48281; Package emacs. (Sat, 08 May 2021 07:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 48281 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> catern.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 48281 <at> debbugs.gnu.org
Subject: Re: bug#48281: buffer_local_value and find_symbol_value duplicate
 functionality
Date: Sat, 08 May 2021 10:10:17 +0300
> From: Spencer Baugh <sbaugh <at> catern.com>
> Date: Fri, 07 May 2021 18:44:33 -0400
> 
> 
> find_symbol_value is described as:
> 
>   Find the value of a symbol, returning Qunbound if it's not bound.
> 
> buffer_local_value does the same, except that it allows one to specify a
> buffer.
> 
> Yet they both implement symbol lookup, without sharing code.  And given
> that the comment above find_symbol_value says "Great care is required
> for this.", I'm guessing that one or both of them may have bugs that the
> other does not.  Especially because buffer_local_value is simpler than
> find_symbol_value, despite doing an ostensibly more complicated job...
> 
> How about unifying them into a single function?  Would a patch doing
> that be accepted?
> 
> Alternatively, maybe I'm missing some detail about why they're
> different?

First, such discussion is better conducted on emacs-devel, not here,
as some of the relevant people don't read the bug list.  Adding
Stefan, who made extensive changes to both functions some 10 years
ago.

More to the point, I'm not sure I understand how you intend to
reconcile the differences in these two functions.  They are similar,
but not identical.  What is the plan for dealing with the differences?

Given that we can safely conflate the two implementations, I don't see
why we won't want to do that.

(The "great care" bit refers to the need to block quitting, btw, not
to the code as a whole.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48281; Package emacs. (Sat, 08 May 2021 13:27:03 GMT) Full text and rfc822 format available.

Message #11 received at 48281 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48281 <at> debbugs.gnu.org, Spencer Baugh <sbaugh <at> catern.com>
Subject: Re: bug#48281: buffer_local_value and find_symbol_value duplicate
 functionality
Date: Sat, 08 May 2021 09:26:31 -0400
>> find_symbol_value is described as:
[...]
>> buffer_local_value does the same, except that it allows one to specify a
>> buffer.
[...]
>> How about unifying them into a single function?  Would a patch doing
>> that be accepted?

Depends on the patch ;-)

>> Alternatively, maybe I'm missing some detail about why they're
>> different?

When I reworked that code I was annoyed by that difference but I had
enough other things to deal with that I didn't bother trying to
reconcile the two functions.

The thing that is important to know about those two functions is that
`find_symbol_value` is performance-critical, whereas
`buffer_local_value` is not.

So any effort to unify the two should focus on not slowing down
`find_symbol_value`.  The fact that here are two functions is acceptable
to me, but indeed the two code paths are uncomfortably different, so I'd
welcome changes (including minor changes) to make them more similar, tho
maybe the best we can do is add comments explaining why the two code
paths give the same result.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48281; Package emacs. (Sat, 02 Jul 2022 13:24:02 GMT) Full text and rfc822 format available.

Message #14 received at 48281 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 48281 <at> debbugs.gnu.org, Spencer Baugh <sbaugh <at> catern.com>,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#48281: buffer_local_value and find_symbol_value duplicate
 functionality
Date: Sat, 02 Jul 2022 15:22:59 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> So any effort to unify the two should focus on not slowing down
> `find_symbol_value`.  The fact that here are two functions is acceptable
> to me, but indeed the two code paths are uncomfortably different, so I'd
> welcome changes (including minor changes) to make them more similar, tho
> maybe the best we can do is add comments explaining why the two code
> paths give the same result.

I think the conclusion here is that it's not worth the added complexity
to merge these two functions, so I've now added a comment about this
instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 02 Jul 2022 13:24:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 48281 <at> debbugs.gnu.org and Spencer Baugh <sbaugh <at> catern.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 02 Jul 2022 13:24:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 31 Jul 2022 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 241 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.