GNU bug report logs - #37450
26.3; `all-completions' PREDICATE for a hash table COLLECTION

Previous Next

Package: emacs;

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.

Full log


View this message in rfc822 format

From: Drew Adams <drew.adams <at> oracle.com>
To: 37450 <at> debbugs.gnu.org
Subject: bug#37450: 26.3; `all-completions' PREDICATE for a hash table COLLECTION
Date: Wed, 18 Sep 2019 11:02:03 -0700 (PDT)
`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''




This bug report was last modified 4 years and 133 days ago.

Previous Next


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