From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: akater Newsgroups: gmane.emacs.bugs 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 Message-ID: <87ee88dmzb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18426"; mail-complaints-to="usenet@ciao.gmane.io" To: 51412@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 26 14:07:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfLEX-0004Xc-KB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 14:07:13 +0200 Original-Received: from localhost ([::1]:33926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfLEW-0001gm-Jl for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 08:07:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfL9b-0007YK-0e for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 08:02:12 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfL9W-0001O3-HD for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 08:02:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfL9W-0005Bs-83 for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 08:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: akater Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Oct 2021 12:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51412 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163524971719938 (code B ref -1); Tue, 26 Oct 2021 12:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Oct 2021 12:01:57 +0000 Original-Received: from localhost ([127.0.0.1]:45317 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfL9Q-0005BV-TN for submit@debbugs.gnu.org; Tue, 26 Oct 2021 08:01:57 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfL9P-0005BO-OR for submit@debbugs.gnu.org; Tue, 26 Oct 2021 08:01:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfL9M-0007VB-ER for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 08:01:55 -0400 Original-Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:38739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfL9H-0001M6-0w for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 08:01:52 -0400 Original-Received: by mail-ed1-x52d.google.com with SMTP id r4so12621940edi.5 for ; Tue, 26 Oct 2021 05:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=k4LkBQQBcmQ/oLrAxv2mnvaSkiWuzopAviPVfPW4ays=; b=GBNGDBSUhs8EWHAOwbAtXntHgI4BjfTGRJPWkCalV2tmEx3xrP3bLTUw0/aq9yf0A7 l3IsRurFF7gL8iACj+aiHI3M2E3D9VYbwo+55lo2AnBULUZXNzwYNnyYPV/kDi3+bxxl SnCHSOunku6z9h34gDDuZ53NhPIIVmShOfONtYCtQ8ZZwW0xJ2zk6yU9D0rTf7AlCea1 vc6JW3yghNFrWcysedq+JJM6rh0lw5p2mI45eWZ6qUg3xuVF0dWVpjFkdqnN7/xmuTr/ co1r48HUMap3U0AiHJhnRpcL4htxo1Obrff5d82DQfnnHa4jGIBzaxlNJ99xGSPBY4IX hAkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=k4LkBQQBcmQ/oLrAxv2mnvaSkiWuzopAviPVfPW4ays=; b=1PSKqrmFLeak3dTv8k7wu0zZFqMKv0N25CpA2NF6/UvOFIKGMw2wiHzwZCI+WVLtKP T0/ke1QjGZtXRf43/mjZHNiS76/epEm5wK6X8Cb10NddgAvq9JgLY0LkdNajtcPqx+mP aiRqoLY4ceTeqNXvKUSeUTZvZ9S2QUxM5EV71+YC1ic0GQPC5HpjXUqIasM9PwZ2QI+C n6q5KlLnI5ka2uw5+yxRMGg+2rYm53JrOjrI6mir73qarukLWXXZdhdbwKxQzxLfOC01 3OOIaEW31SKkncOJSOQjydy3AqvfO9Mi7SU8h9zqgo31VjRf/I06jb/P2p2m1QT/FZJf z00w== X-Gm-Message-State: AOAM532Oe0gs9Wwh6kwxUDu4smk0sdcdbFHqgRm8dHMVtL7D+H7tEK67 V1xSX1rWcwkrREFulGjd1/lv7sFoHHw= X-Google-Smtp-Source: ABdhPJzV949VTyC2t5MX3/3juod4OOFRjpemP6FxmoAmsq1tedR3Dcln1Al2iz25CqaY+4xZ8UPpgg== X-Received: by 2002:a17:906:a14a:: with SMTP id bu10mr28615110ejb.540.1635249696418; Tue, 26 Oct 2021 05:01:36 -0700 (PDT) Original-Received: from localhost ([185.31.175.226]) by smtp.googlemail.com with ESMTPSA id e6sm4557066ejs.112.2021.10.26.05.01.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 05:01:36 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=nuclearspace@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218377 Archived-At: 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=3D(a . #1#) nil ni= l). Note that (cl-map 'list #'identity '#1=3D(a . #1#) nil) doesn't fail so this is at the very least inconsistent. N.B.: CL spec says =E2=80=9CShould= be prepared to signal an error=E2=80=9D 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.