GNU bug report logs - #50110
26.3; Doc of `assoc': TESTFN optional arg

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 18 Aug 2021 17:37:02 UTC

Severity: minor

Found in version 26.3

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#50110: closed (26.3; Doc of `assoc': TESTFN optional arg)
Date: Wed, 18 Aug 2021 19:10:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 18 Aug 2021 22:08:53 +0300
with message-id <83mtpe370a.fsf <at> gnu.org>
and subject line Re: [External] : Re: bug#50110: 26.3; Doc of `assoc': TESTFN optional arg
has caused the debbugs.gnu.org bug report #50110,
regarding 26.3; Doc of `assoc': TESTFN optional arg
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
50110: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=50110
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Drew Adams <drew.adams <at> oracle.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 26.3; Doc of `assoc': TESTFN optional arg
Date: Wed, 18 Aug 2021 17:36:11 +0000
Neither the `assoc' doc string nor the Elisp manual, node `Association
Lists' explains the order of the args that get passed to TESTFN.

It's just as reasonable to expect that the pattern is the first arg to
TESTFN, instead of, as is actually the case, the second arg.

E.g., one could suppose that this would work (return the first element):

(setq trees '(("pine" . "cones") ("oak" . "acorns")))

(assoc ".*ine" trees #'string-match-p)

But in fact this is what you need:

(assoc ".*ine" trees (lambda (x regexp) (string-match-p regexp x)))

Please consider documenting the arg order for TESTFN.

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.19042
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''



[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 50110-done <at> debbugs.gnu.org
Subject: Re: [External] : Re: bug#50110: 26.3; Doc of `assoc': TESTFN optional
 arg
Date: Wed, 18 Aug 2021 22:08:53 +0300
> From: Drew Adams <drew.adams <at> oracle.com>
> CC: "50110 <at> debbugs.gnu.org" <50110 <at> debbugs.gnu.org>
> Date: Wed, 18 Aug 2021 18:41:00 +0000
> 
> > > Neither the `assoc' doc string nor the Elisp manual, node `Association
> > > Lists' explains the order of the args that get passed to TESTFN.
> > 
> > It's a function that tests 2 objects for equality, so why does the
> > order matter?
> > 
> > > It's just as reasonable to expect that the pattern is the first arg to
> > > TESTFN, instead of, as is actually the case, the second arg.
> > 
> > There's no "pattern" in the doc string, so I don't think I understand
> > what you are describing here.
> 
> I gave examples.  What part is unclear?  To know how to use
> `string-match-p' for testing you need to know the arg order
> for TESTFN.  The arg order matters for `string-match-p'.

OK, I added description of how TESTFN is called.


This bug report was last modified 3 years and 339 days ago.

Previous Next


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