GNU bug report logs -
#37450
26.3; `all-completions' PREDICATE for a hash table COLLECTION
Previous Next
Reported by: Drew Adams <drew.adams <at> oracle.com>
Date: Wed, 18 Sep 2019 18:03:01 UTC
Severity: minor
Tags: wontfix
Found in version 26.3
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 37450 in the body.
You can then email your comments to 37450 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#37450
; Package
emacs
.
(Wed, 18 Sep 2019 18:03:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Drew Adams <drew.adams <at> oracle.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 18 Sep 2019 18:03:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
`C-h f all-completions' says this for this case:
If COLLECTION is a hash-table, predicate is called with two arguments:
the key and the value.
Why does the PREDICATE function need to accept a VALUE argument, as well
as a KEY argument? When an alist or obarray is used, the only thing
PREDICATE needs is the KEY to look up. I would think that that's the
only thing needed for a hash table also, logically.
I had this in one of my functions, back when `bbdb-complete-mail' used
an alist, before it changed to using hash-table `bbdb-hashtable':
(all-completions orig
THE-BBDB-ALIST
(lambda (sym)
(when (bbdb-completion-predicate sym)
(push sym all-comps))))
I had to change that to this, adding an (unused?) arg for the PREDICATE:
(all-completions orig
bbdb-hashtable'
(lambda (sym __)
(when (bbdb-completion-predicate sym)
(push sym all-comps))))
Why should the PREDICATE function need to change, now that a hash table
is used? The VALUE arg for the PREDICATE isn't necessary for hash-table
lookup, right? If that's right then why not have the PREDICATE accept
the KEY as a minimum? If some code wants to additionally include a
VALUE arg, it could do that. Can't just `all-completions' DTRT,
applying the PREDICATE to the provided KEY and VALUE if provided, else
nil for VALUE?
If `all-completions' were coded in Lisp I might take a look, to see
whether there's a good reason for PREDICATE to require 2 args when the
second arg to `all-completions' is a hash table. So far, I'm just
wondering. If all that's logically required is a KEY lookup, why make
an exception for hash tables, forcing the PREDICATE to accept also an
(unused?) VALUE?
In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.17763
Configured using:
`configure --without-dbus --host=x86_64-w64-mingw32
--without-compress-install 'CFLAGS=-O2 -static -g3''
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#37450
; Package
emacs
.
(Wed, 18 Sep 2019 18:29:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 37450 <at> debbugs.gnu.org (full text, mbox):
> (all-completions orig
> THE-BBDB-ALIST
> (lambda (sym)
> (when (bbdb-completion-predicate sym)
> (push sym all-comps))))
>
> I had to change that to this, adding an (unused?) arg for the PREDICATE:
>
> (all-completions orig
> bbdb-hashtable'
> (lambda (sym __)
> (when (bbdb-completion-predicate sym)
> (push sym all-comps))))
I shouldn't have been so definitive about that "fix".
It apparently didn't work - the user now reports a
different error message, saying "Something like two
arguments but expected one." I don't use BBDB, so
I'm flying a bit blind on this.
Hope my bug report makes some sense in any case.
My question seems reasonable, at least in my relative
ignorance: why must the PREDICATE take also a VALUE
arg when COLLECTION is a hash table? Why isn't KEY
lookup sufficient?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#37450
; Package
emacs
.
(Sat, 30 Jan 2021 07:25:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 37450 <at> debbugs.gnu.org (full text, mbox):
Drew Adams <drew.adams <at> oracle.com> writes:
> Hope my bug report makes some sense in any case.
> My question seems reasonable, at least in my relative
> ignorance: why must the PREDICATE take also a VALUE
> arg when COLLECTION is a hash table? Why isn't KEY
> lookup sufficient?
Presumably because it's more convenient sometimes? In any case, this
interface can't be changed, because that would break a lot of code.
Closing.
--
(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, 30 Jan 2021 07:25:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
37450 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 30 Jan 2021 07:25: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
.
(Sat, 27 Feb 2021 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 30 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.