GNU bug report logs - #40972
27.0.91; assoc TESTFN's args reversed?

Previous Next

Package: emacs;

Reported by: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>

Date: Wed, 29 Apr 2020 21:16:02 UTC

Severity: minor

Tags: notabug, wontfix

Found in version 27.0.91

Done: Stefan Kangas <stefan <at> marxist.se>

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 40972 in the body.
You can then email your comments to 40972 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#40972; Package emacs. (Wed, 29 Apr 2020 21:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Shigeru Fukaya <shigeru.fukaya <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 29 Apr 2020 21:16:02 GMT) Full text and rfc822 format available.

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

From: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.91; assoc TESTFN's args reversed?
Date: Thu, 30 Apr 2020 06:15:09 +0900
It seems to me, for third argument of `assoc', arguments are passed in a
reverse order.

(assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
       (lambda (x y) (equal (concat "cl-" x) y)))
==> nil

(assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
       (lambda (y x) (equal (concat "cl-" x) y)))
==> ("cl-assoc" A)

Or, is this intended behavior??

Thanks,
Shigeru




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40972; Package emacs. (Wed, 29 Apr 2020 23:31:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Cc: 40972 <at> debbugs.gnu.org
Subject: Re: bug#40972: 27.0.91; assoc TESTFN's args reversed?
Date: Thu, 30 Apr 2020 01:30:13 +0200
Shigeru Fukaya <shigeru.fukaya <at> gmail.com> writes:

> It seems to me, for third argument of `assoc', arguments are passed in a
> reverse order.
>
> (assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
>        (lambda (x y) (equal (concat "cl-" x) y)))
> ==> nil
>
> (assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
>        (lambda (y x) (equal (concat "cl-" x) y)))
> ==> ("cl-assoc" A)
>
> Or, is this intended behavior??

Dunno what others expect, but note that your predicate is not an
equality predicate (it's not symmetric), and the docstring doesn't
specify a behavior for this case.

Michael.




Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 20 May 2020 15:49:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40972; Package emacs. (Wed, 09 Sep 2020 13:23:03 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 40972 <at> debbugs.gnu.org, Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Subject: Re: bug#40972: 27.0.91; assoc TESTFN's args reversed?
Date: Wed, 9 Sep 2020 06:22:18 -0700
tags 40972 + wontfix notabug
close 40972
thanks

Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Shigeru Fukaya <shigeru.fukaya <at> gmail.com> writes:
>
>> It seems to me, for third argument of `assoc', arguments are passed in a
>> reverse order.
>>
>> (assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
>>        (lambda (x y) (equal (concat "cl-" x) y)))
>> ==> nil
>>
>> (assoc "assoc" '(("cl-assoc" A) ("cl-member" B))
>>        (lambda (y x) (equal (concat "cl-" x) y)))
>> ==> ("cl-assoc" A)
>>
>> Or, is this intended behavior??
>
> Dunno what others expect, but note that your predicate is not an
> equality predicate (it's not symmetric), and the docstring doesn't
> specify a behavior for this case.

As Michael points out, the equality operation is symmetric and therefore
by definition the order does not matter.  We therefore cannot say if X=Y
or Y=X is "more correct": they are equivalent.

In any case, I think it will cause more problems to switch the argument
order at this point, since there might be code out there that relies on
this (undocumented) behavior.  So I'm closing this bug.




Added tag(s) wontfix and notabug. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 09 Sep 2020 13:23:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 40972 <at> debbugs.gnu.org and Shigeru Fukaya <shigeru.fukaya <at> gmail.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 09 Sep 2020 13:23:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40972; Package emacs. (Wed, 09 Sep 2020 14:47:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 40972 <at> debbugs.gnu.org,
 Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Subject: Re: bug#40972: 27.0.91; assoc TESTFN's args reversed? 
Date: Wed, 9 Sep 2020 16:46:43 +0200
> As Michael points out, the equality operation is symmetric and therefore by definition the order does not matter. We therefore cannot say if X=Y or Y=X is "more correct": they are equivalent.
> 
> In any case, I think it will cause more problems to switch the argument order at this point, since there might be code out there that relies on this (undocumented) behavior. So I'm closing this bug. 

It's quite possible that the current argument order was intended but never really documented. It's occasionally exploited (see image-converter--filter-formats). The asymmetry is stated more explicitly in the doc string and manual entry for assoc-default. Closing the bug is probably wisest.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40972; Package emacs. (Wed, 09 Sep 2020 15:19:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 40972 <at> debbugs.gnu.org,
 Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Subject: Re: bug#40972: 27.0.91; assoc TESTFN's args reversed?
Date: Wed, 9 Sep 2020 08:18:30 -0700
Mattias Engdegård <mattiase <at> acm.org> writes:

> It's quite possible that the current argument order was intended but
> never really documented. It's occasionally exploited (see
> image-converter--filter-formats). The asymmetry is stated more
> explicitly in the doc string and manual entry for
> assoc-default. Closing the bug is probably wisest.

Should we fix the doc string for assoc to match assoc-default?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40972; Package emacs. (Wed, 09 Sep 2020 15:52:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Stefan Kangas <stefan <at> marxist.se>, Nicolas Petton <nicolas <at> petton.fr>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 40972 <at> debbugs.gnu.org,
 Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Subject: Re: bug#40972: 27.0.91; assoc TESTFN's args reversed?
Date: Wed, 9 Sep 2020 17:51:46 +0200
9 sep. 2020 kl. 17.18 skrev Stefan Kangas <stefan <at> marxist.se>:

>> It's quite possible that the current argument order was intended but
>> never really documented. It's occasionally exploited (see
>> image-converter--filter-formats). The asymmetry is stated more
>> explicitly in the doc string and manual entry for
>> assoc-default. Closing the bug is probably wisest.
> 
> Should we fix the doc string for assoc to match assoc-default?

Good question. The TESTFN parameter was added recently (in Emacs time) to assoc (0bece6c6815). Nicolas, did you intend it to be symmetric, or defined in an asymmetric way like in assoc-default?





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 08 Oct 2020 11:24:08 GMT) Full text and rfc822 format available.

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

Previous Next


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