GNU bug report logs -
#51412
29.0.50; cl--mapcar-many fails inconsistently in the presence of circular lists; other shortcomings
Previous Next
Full log
View this message in rfc822 format
cl--mapcar-many is used as a backend for implementing several cl-
functions in cl-extra. To deal with arbitrary number of arguments
(passed to cl--mapcar-many as list cl-seq), it goes through them all
whenever there are more than 2, in advance, and attempts to compute the
minimal length.
This fails if any of the arguments is a circular list.
To reproduce, just evaluate (cl-map 'list #'identity '#1=(a . #1#) nil nil).
Note that (cl-map 'list #'identity '#1=(a . #1#) nil) doesn't fail so
this is at the very least inconsistent. N.B.: CL spec says “Should be
prepared to signal an error” for improper lists for such functions.
Long story short, this means circular lists can be supported by CL
implementations according to CL spec.
Other shortcomings: going through all sequences in advance is very
inefficient. mapcar-many also checks sequence types at runtime even
though they are known in advance which is also wasteful.
The mechanism used in recent suggested implementation of cl-map-into
https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg00636.html
could be used to reimplement other sequence-oriented cl-extra functions
and resolve these issues, if it's merged.
I wrote some supporting macros there with a view towards this use; this
bug report is partially an apology for them.
This bug report was last modified 2 years and 275 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.