all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#40972: 27.0.91; assoc TESTFN's args reversed?
@ 2020-04-29 21:15 Shigeru Fukaya
  2020-04-29 23:30 ` Michael Heerdegen
  2020-09-09 14:46 ` Mattias Engdegård
  0 siblings, 2 replies; 6+ messages in thread
From: Shigeru Fukaya @ 2020-04-29 21:15 UTC (permalink / raw)
  To: 40972

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40972: 27.0.91; assoc TESTFN's args reversed?
  2020-04-29 21:15 bug#40972: 27.0.91; assoc TESTFN's args reversed? Shigeru Fukaya
@ 2020-04-29 23:30 ` Michael Heerdegen
  2020-09-09 13:22   ` Stefan Kangas
  2020-09-09 14:46 ` Mattias Engdegård
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2020-04-29 23:30 UTC (permalink / raw)
  To: Shigeru Fukaya; +Cc: 40972

Shigeru Fukaya <shigeru.fukaya@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40972: 27.0.91; assoc TESTFN's args reversed?
  2020-04-29 23:30 ` Michael Heerdegen
@ 2020-09-09 13:22   ` Stefan Kangas
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2020-09-09 13:22 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 40972, Shigeru Fukaya

tags 40972 + wontfix notabug
close 40972
thanks

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Shigeru Fukaya <shigeru.fukaya@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40972: 27.0.91; assoc TESTFN's args reversed?
  2020-04-29 21:15 bug#40972: 27.0.91; assoc TESTFN's args reversed? Shigeru Fukaya
  2020-04-29 23:30 ` Michael Heerdegen
@ 2020-09-09 14:46 ` Mattias Engdegård
  2020-09-09 15:18   ` Stefan Kangas
  1 sibling, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2020-09-09 14:46 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Michael Heerdegen, 40972, Shigeru Fukaya

> 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.







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40972: 27.0.91; assoc TESTFN's args reversed?
  2020-09-09 14:46 ` Mattias Engdegård
@ 2020-09-09 15:18   ` Stefan Kangas
  2020-09-09 15:51     ` Mattias Engdegård
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2020-09-09 15:18 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Michael Heerdegen, 40972, Shigeru Fukaya

Mattias Engdegård <mattiase@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?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#40972: 27.0.91; assoc TESTFN's args reversed?
  2020-09-09 15:18   ` Stefan Kangas
@ 2020-09-09 15:51     ` Mattias Engdegård
  0 siblings, 0 replies; 6+ messages in thread
From: Mattias Engdegård @ 2020-09-09 15:51 UTC (permalink / raw)
  To: Stefan Kangas, Nicolas Petton; +Cc: Michael Heerdegen, 40972, Shigeru Fukaya

9 sep. 2020 kl. 17.18 skrev Stefan Kangas <stefan@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?






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-09 15:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29 21:15 bug#40972: 27.0.91; assoc TESTFN's args reversed? Shigeru Fukaya
2020-04-29 23:30 ` Michael Heerdegen
2020-09-09 13:22   ` Stefan Kangas
2020-09-09 14:46 ` Mattias Engdegård
2020-09-09 15:18   ` Stefan Kangas
2020-09-09 15:51     ` Mattias Engdegård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.