bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51412: 29.0.50; cl--mapcar-many fails inconsistently in the presence


From: akater
Subject: bug#51412: 29.0.50; cl--mapcar-many fails inconsistently in the presence of circular lists; other shortcomings
Date: Tue, 26 Oct 2021 11:50:00 +0000

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]