unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: akater <nuclearspace@gmail.com>
To: 51412@debbugs.gnu.org
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	[thread overview]
Message-ID: <87ee88dmzb.fsf@gmail.com> (raw)

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	other threads:[~2021-10-26 11:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 11:50 akater [this message]
2022-09-14 18:38 ` bug#51412: 29.0.50; cl--mapcar-many fails inconsistently in the presence of circular lists; other shortcomings Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ee88dmzb.fsf@gmail.com \
    --to=nuclearspace@gmail.com \
    --cc=51412@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).