From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Christopher Wellons Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 May 2018 13:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 31641@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.152759956617655 (code B ref -1); Tue, 29 May 2018 13:13:01 +0000 Received: (at submit) by debbugs.gnu.org; 29 May 2018 13:12:46 +0000 Received: from localhost ([127.0.0.1]:53279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNeQf-0004ah-Mj for submit@debbugs.gnu.org; Tue, 29 May 2018 09:12:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNeQe-0004aV-NL for submit@debbugs.gnu.org; Tue, 29 May 2018 09:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNeQY-0007F5-Ru for submit@debbugs.gnu.org; Tue, 29 May 2018 09:12:39 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49559) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNeQY-0007Ez-NQ for submit@debbugs.gnu.org; Tue, 29 May 2018 09:12:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNeQX-000083-OR for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 09:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNeQT-0007Cu-On for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 09:12:37 -0400 Received: from mail.nullprogram.com ([192.241.191.137]:41964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNeQT-0007C9-L4 for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 09:12:33 -0400 Received: from nullprogram.com (localhost [127.0.0.1]) by mail.nullprogram.com (Postfix) with ESMTPS id D9AA9C0A34 for ; Tue, 29 May 2018 09:12:31 -0400 (EDT) Date: Tue, 29 May 2018 09:12:30 -0400 From: Christopher Wellons Message-ID: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) When byte-compiling an iter-do form with a variable intended to be left=20 unused, the compiler emits a false warning: ;;; -*- lexical-binding: t; -*- (require 'generator) (iter-do (_ i)) ;; -> "Warning: variable =E2=80=98_=E2=80=99 not left unused" Giving the variable a name has the opposite effect, though it's not=20 a false warning in this case: (iter-do (v i)) ;; -> "Unused lexical variable =E2=80=98v=E2=80=99" This issue does not occur with similar, long-established forms: ;;; -*- lexical-binding: t; -*- (dolist (_ '(a b c))) (dotimes (_ 10)) ;; -> no warnings From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 May 2018 22:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Christopher Wellons Cc: 31641@debbugs.gnu.org Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.152763204610184 (code B ref 31641); Tue, 29 May 2018 22:15:02 +0000 Received: (at 31641) by debbugs.gnu.org; 29 May 2018 22:14:06 +0000 Received: from localhost ([127.0.0.1]:54382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNmsY-0002e7-9V for submit@debbugs.gnu.org; Tue, 29 May 2018 18:14:06 -0400 Received: from mail-it0-f44.google.com ([209.85.214.44]:54937) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNmsR-0002dM-J9; Tue, 29 May 2018 18:14:02 -0400 Received: by mail-it0-f44.google.com with SMTP id 76-v6so5394890itx.4; Tue, 29 May 2018 15:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=tGpjA5qEZvfZ4KdvhkN99vKZ04cmfk1IwgNmcoVBvow=; b=Juw7fa1twUfTJafnbAqqd52lTXZZSPGRArRJLV6g2e8ZNe/gzl005aX/OcXYGQ1ILk U+paE5DJRuAmrzGksMTXd3sCOVPUGmM//XcHkECWL+K7zEnTFoAlWDhgB7w4njjHy3Nt deeTMQEoBiBiFP9T+NfRqutrXGWww+8t+HV7YQOWbPznX14MJmBR33rE7odajhcwEqjJ aZWJe3EEZ9Uxtt9Y6oIRB7Mm8iIEFdxxWGRWmswzis3eJhqSjr1s9eY6bu0R+t0+R1qY PZ5Eek0DB2AJq3EMZkegthlaaI0+R3krpMsBJJYbKJpPZpMYOd/xVPjjZBeRqFp4yhw0 Gi7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=tGpjA5qEZvfZ4KdvhkN99vKZ04cmfk1IwgNmcoVBvow=; b=tezXckzbfcvDP/HaOetA5nMsQWlHH3WMjNfSjGMmQuFxgHadiD77dV9kgJWAjaxOcR c0xpvPEIgjQ5+rWeFuXWoCG6J3WF/4rYwgAbbrPe8pbE/8h/Kf0PcdWW1Fbh7Zc8zQ7X gupoXZfOVWqu1NkuEMonOuE8qBAZRIY9El6pKotTew3zoRLrejrx1HuScwVzyEv3r/Kd Nw1EJQEwV0TYoIjMw9CxMvyb2dPH2NGeDKj0OCIFdVoNVoNsMYGlPqj5Eau9CMQ2nuIy 1OrmeEV3a3q4QiPUJtvu60Gkla6pJh+vEdJ65vSiypQeAiTB92o6oqTOi/24G9DXT4if lGbg== X-Gm-Message-State: ALKqPwdExgkIjHFY0BBQSu8pvstUVz4HBcvvL4YZjAIeQh07jx9iliW3 mIv56bGMIiYGeFsVucD17qzwZQ== X-Google-Smtp-Source: ADUXVKJON9BOKrogNOuArMTTtmR3b8+hmdCRNo6ILcSdG2oeOvA/9K5vj9uSMmc3/gFezOMpt2rJOw== X-Received: by 2002:a6b:e90d:: with SMTP id u13-v6mr214635iof.22.1527632033652; Tue, 29 May 2018 15:13:53 -0700 (PDT) Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id q21-v6sm11171672itb.4.2018.05.29.15.13.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 15:13:52 -0700 (PDT) From: Noam Postavsky References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> Date: Tue, 29 May 2018 18:13:50 -0400 In-Reply-To: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> (Christopher Wellons's message of "Tue, 29 May 2018 09:12:30 -0400") Message-ID: <87in76cdpd.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 31641 + confirmed severity 31641 minor quit Christopher Wellons writes: > When byte-compiling an iter-do form with a variable intended to be > left unused, the compiler emits a false warning: > > ;;; -*- lexical-binding: t; -*- > (require 'generator) > (iter-do (_ i)) > ;; -> "Warning: variable =E2=80=98_=E2=80=99 not left unused" Looking at the expansion, I guess the setf should be dropped if the variable name starts with _. (let (_ #3=3D#:iter-do-result11 (#1=3D#:iter-do-iterator-done8 nil) (#2=3D#:iter-do-iterator10 i)) (while (not #1#) (condition-case #4=3D#:iter-do-condition9 (setf _ (iter-next #2#)) (iter-end-of-sequence (setf #3# (cdr #4#)) (setf #1# t))) (unless #1#)) #3#) From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Noam Postavsky Cc: Christopher Wellons , Daniel Colascione , 31641@debbugs.gnu.org, Stefan Monnier Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.161243314323031 (code B ref 31641); Thu, 04 Feb 2021 10:06:02 +0000 Received: (at 31641) by debbugs.gnu.org; 4 Feb 2021 10:05:43 +0000 Received: from localhost ([127.0.0.1]:39768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bWB-0005zP-5G for submit@debbugs.gnu.org; Thu, 04 Feb 2021 05:05:43 -0500 Received: from quimby.gnus.org ([95.216.78.240]:55416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bW9-0005yy-AU for 31641@debbugs.gnu.org; Thu, 04 Feb 2021 05:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=sav7jVW1axezH4YiPbegBCBtg1C7TwAjYbnBx4EGqX0=; b=hR/vy8BOPWcsjsFKUGgG3VzZUS 6YfgCRuWWM4pRCxTDELN8wpMglXcYcz3hehHWB12k5dfD+qmRLOpwBfWYcD+WYrav/GQsm9By1dKf 8cCe+3JZUloyTxBq6BlIZ6ni7XPwFRX0fsY0vSt4lrmvE9GccseoPivCp8AIzqaW/qIY=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7bVu-0005Vn-AL; Thu, 04 Feb 2021 11:05:29 +0100 From: Lars Ingebrigtsen References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> X-Now-Playing: Drew McDowall's _Rogue Pulse: Gravity Collapse (9)_: "Interstitial" Date: Thu, 04 Feb 2021 11:05:24 +0100 In-Reply-To: <87in76cdpd.fsf@gmail.com> (Noam Postavsky's message of "Tue, 29 May 2018 18:13:50 -0400") Message-ID: <87czxgtafv.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Noam Postavsky writes: >> When byte-compiling an iter-do form with a variable intended to be >> left unused, the compiler emits a false warning: >> >> ;;; -*- lexical-binding: t; -*- >> (require 'generator) >> (iter-do (_ i [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Noam Postavsky writes: >> When byte-compiling an iter-do form with a variable intended to be >> left unused, the compiler emits a false warning: >> >> ;;; -*- lexical-binding: t; -*- >> (require 'generator) >> (iter-do (_ i)) >> ;; -> "Warning: variable =E2=80=98_=E2=80=99 not left unused" > > Looking at the expansion, I guess the setf should be dropped if the > variable name starts with _. > > (let (_ > #3=3D#:iter-do-result11 > (#1=3D#:iter-do-iterator-done8 nil) > (#2=3D#:iter-do-iterator10 i)) > (while (not #1#) > (condition-case #4=3D#:iter-do-condition9 > (setf _ (iter-next #2#)) > (iter-end-of-sequence > (setf #3# (cdr #4#)) > (setf #1# t))) > (unless #1#)) > #3#) The following patch does this, but I'm not sure whether this is correct or not -- in other cases, the _ convention just removes the warning, but doesn't change the semantics. I wondered whether we could just suppress this warning like this: ,(if (string-match-p "\\`_" (symbol-name var)) `(with-suppressed-warnings ((not-unused ,var)) (setf ,var (iter-next ,it-symbol))) `(setf ,var (iter-next ,it-symbol))) But no, cconv--analyze-use is called too early, and would have to be taught about `with-suppressed-warnings'... which, looking at the code, isn't immediately obvious how to do. So does anybody have any ideas here? diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 9eb6d95964..0b644cc72c 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -731,7 +731,10 @@ iter-do (,it-symbol ,iterator)) (while (not ,done-symbol) (condition-case ,condition-symbol - (setf ,var (iter-next ,it-symbol)) + ;; Variables that start with an underscore shouldn't be set. + ,(if (string-match-p "\\`_" (symbol-name var)) + nil + `(setf ,var (iter-next ,it-symbol))) (iter-end-of-sequence (setf ,result-symbol (cdr ,condition-symbol)) (setf ,done-symbol t))) --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 16:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Lars Ingebrigtsen Cc: Christopher Wellons , Daniel Colascione , 31641@debbugs.gnu.org, Noam Postavsky Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.1612456601929 (code B ref 31641); Thu, 04 Feb 2021 16:37:01 +0000 Received: (at 31641) by debbugs.gnu.org; 4 Feb 2021 16:36:41 +0000 Received: from localhost ([127.0.0.1]:42123 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7hcW-0000Eu-RN for submit@debbugs.gnu.org; Thu, 04 Feb 2021 11:36:41 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7hcR-0000Ec-Sk for 31641@debbugs.gnu.org; Thu, 04 Feb 2021 11:36:39 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 632B5814D7; Thu, 4 Feb 2021 11:36:30 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A5EBF80976; Thu, 4 Feb 2021 11:36:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612456588; bh=RbkNmIdLMxguZMKj1ACjbBwZSB8+DQmMtj51t/+3Lf0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=icoNgeXAwoR8OT/Mz5wLZLTIpGSKumwv/vsUJdLa3P6shZRjJ1AGp2DbHw/UycUv7 ORYUg4TR4KZRukEpS95K07yXh/Y4rsZbkImLK0Kwn+lCfoRjH+mwHYC/A81PJRoFBp VZpnQIrPmUtpDSJH3vUPrDkScWvnmprV19O/ZuXKdLs3tM7SFJvm2uj2eZyuQ47PnL 68Go+eoXkGIiWoNQfLfHUYR5TYZwzveSWJlP880XxSmkf2lBZjAs6Gc95ADdsOsHP7 ciTtB9anZcn4Fn0HLUfDK6YULK0MfA9VawC4/IhjiaR6+Ces4pSg/xPIGHm2PU/CK0 TUnQal0kpr7Xw== Received: from alfajor (76-10-182-85.dsl.teksavvy.com [76.10.182.85]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 563B81201C3; Thu, 4 Feb 2021 11:36:28 -0500 (EST) From: Stefan Monnier Message-ID: References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> Date: Thu, 04 Feb 2021 11:36:27 -0500 In-Reply-To: <87czxgtafv.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 04 Feb 2021 11:05:24 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.008 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> When byte-compiling an iter-do form with a variable intended to be >>> left unused, the compiler emits a false warning: >>> >>> ;;; -*- lexical-binding: t; -*- >>> (require 'generator) >>> (iter-do (_ i)) >>> ;; -> "Warning: variable =E2=80=98_=E2=80=99 not left unused" >> >> Looking at the expansion, I guess the setf should be dropped if the >> variable name starts with _. >> >> (let (_ >> #3=3D#:iter-do-result11 >> (#1=3D#:iter-do-iterator-done8 nil) >> (#2=3D#:iter-do-iterator10 i)) >> (while (not #1#) >> (condition-case #4=3D#:iter-do-condition9 >> (setf _ (iter-next #2#)) >> (iter-end-of-sequence >> (setf #3# (cdr #4#)) >> (setf #1# t))) >> (unless #1#)) >> #3#) FWIW, I find the above expansion to provide somewhat "dirty" semantics in the sense that (let ((funs '())) (iter-do (n i) (push (lambda () n) funs)) funs) will return a list of functions which all return the same value (the last `n`). You can clean up this semantics and the warning at the same time by using an expansion like: (let (#3=3D#:iter-do-result11 (#1=3D#:iter-do-iterator-done8 nil) (#2=3D#:iter-do-iterator10 i)) (while (not #1#) (let ((_ (condition-case #4=3D#:iter-do-condition9 (iter-next #2#) (iter-end-of-sequence (setf #3# (cdr #4#)) (setf #1# t))) (unless #1# [BODY]) #3#) BTW, I think we can remove the duplicate #1 test by moving the body of the `while` into its test, e.g.: (let (#3=3D#:iter-do-result11 (#1=3D#:iter-do-iterator-done8 nil) (#2=3D#:iter-do-iterator10 i)) (while (let ((_ (condition-case #4=3D#:iter-do-condition9 (iter-next #2#) (iter-end-of-sequence (setf #3# (cdr #4#)) (setf #1# t))))) (unless #1# [BODY] t))) #3#) It's too bad that [BODY] can throw `iter-end-of-sequence`, since otherwise we could move the `condition-case` outside of the loop and get something more efficient. Stefan > The following patch does this, but I'm not sure whether this is correct > or not -- in other cases, the _ convention just removes the warning, but > doesn't change the semantics. > > I wondered whether we could just suppress this warning like this: > > ,(if (string-match-p "\\`_" (symbol-name var)) > `(with-suppressed-warnings ((not-unused ,var)) > (setf ,var (iter-next ,it-symbol))) > `(setf ,var (iter-next ,it-symbol))) > > But no, cconv--analyze-use is called too early, and would have to be > taught about `with-suppressed-warnings'... which, looking at the code, > isn't immediately obvious how to do. > > So does anybody have any ideas here? > > diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el > index 9eb6d95964..0b644cc72c 100644 > --- a/lisp/emacs-lisp/generator.el > +++ b/lisp/emacs-lisp/generator.el > @@ -731,7 +731,10 @@ iter-do > (,it-symbol ,iterator)) > (while (not ,done-symbol) > (condition-case ,condition-symbol > - (setf ,var (iter-next ,it-symbol)) > + ;; Variables that start with an underscore shouldn't be set. > + ,(if (string-match-p "\\`_" (symbol-name var)) > + nil > + `(setf ,var (iter-next ,it-symbol))) > (iter-end-of-sequence > (setf ,result-symbol (cdr ,condition-symbol)) > (setf ,done-symbol t))) From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Feb 2021 08:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Stefan Monnier Cc: Christopher Wellons , Daniel Colascione , 31641@debbugs.gnu.org, Noam Postavsky Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.161251521127978 (code B ref 31641); Fri, 05 Feb 2021 08:54:01 +0000 Received: (at 31641) by debbugs.gnu.org; 5 Feb 2021 08:53:31 +0000 Received: from localhost ([127.0.0.1]:42728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7wrq-0007HC-Rf for submit@debbugs.gnu.org; Fri, 05 Feb 2021 03:53:31 -0500 Received: from quimby.gnus.org ([95.216.78.240]:38422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7wrm-0007Gx-UO for 31641@debbugs.gnu.org; Fri, 05 Feb 2021 03:53:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=a15SoZuVk4ctxk4j5W1stTl65IwO1/hHsOiyEqK6Ljc=; b=Ar4P8wOg0vw163ScCebMkSqbrw jUDgNz0egdZuKKkyM/LqEeYgYRvrBeb4kuGpIHqAG2OvPCXlGtdPgJBptlRNvW2Fk6iEO+H7emda+ 1U7XWVMFswwpzDgwNbGhVOq2VT6wtoiLEK/6oHzEXmS6gjO43R91za0rYi7Z15fPZUW8=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7wrZ-0000aT-8a; Fri, 05 Feb 2021 09:53:18 +0100 From: Lars Ingebrigtsen References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEVbJYRgJoR8UYKM fm5ROkbY1sf///8tWHUmAAAAAWJLR0QGYWa4fQAAAAd0SU1FB+UCBQgeLC/JgUcAAAGqSURBVDjL bZRdloMgDIVh2nkH7bxXOzsgvncOuAKa/W9lkhtQ+5NzaCUfNzei6Nwh/P4fjnkXkQ3O+xjdW0gy duDDMa9EgXev5aIzBRYEW7eHKGaNq4xBxoTZ5BVgHodhGuIwhRjnWd1da/lwC5oxD+fjlgzOdw/r xeILKQMoFOb5djP7UW12xSCWszYwDdNTqT2C+wD6dnxQ+OCDfwLSseSwryYT3/IevwrG9zwVgCwX r6HgnBrIG88AJ81kTK2MzPMVpSj1lQQutf9UkVJaayvRRUEVKdHCdOggZyjGnIiZbCVXU6rHWVZU XlAoG2jmJWVmtiJcCSvuAi7SnZVSwI9SpEmU2jxKWXh5aLcpAJAkagP8QNPN/ADSAxd3eWNOopA8 bm6Fh/St4KKAKTfzouYEQK2Zst1HyXd5qCNAk/T2gseWJFaTDHeT6muouyv7KAMKq6WlvmsDNSe5 D4afbokB+SHuUYpu+w9KMWErLSrAaHUSrbxLDCxVkTxGXqu52BOUa4CV69LtTUFLURsBNfEOhtmi /+M4f/qWtO+JnlXfjoN+UmTYmfoHNuavkJlx2q0AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDIt MDVUMDg6MzA6NDQrMDA6MDCmvUZQAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA1VDA4OjMw OjQ0KzAwOjAw1+D+7AAAAABJRU5ErkJggg== X-Now-Playing: Shirley & Dolly Collins's _Harking Back_: "Fare Thee Well My Dearest Dear" Date: Fri, 05 Feb 2021 09:53:10 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 04 Feb 2021 11:36:27 -0500") Message-ID: <875z36nbex.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: > FWIW, I find the above expansion to provide somewhat "dirty" semantics > in the sense that > > (let ((funs '())) > (iter-do (n i) (push (lambda () n) funs)) > funs) > > will return a list of functio [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > FWIW, I find the above expansion to provide somewhat "dirty" semantics > in the sense that > > (let ((funs '())) > (iter-do (n i) (push (lambda () n) funs)) > funs) > > will return a list of functions which all return the same value (the > last `n`). > > You can clean up this semantics and the warning at the same time by > using an expansion like: If I'm reading that correctly, that does seem like more obvious semantics, but is it too late to change this now? I'm not sure how much generator.el is used in the wild yet... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Feb 2021 15:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Lars Ingebrigtsen Cc: Christopher Wellons , Daniel Colascione , 31641@debbugs.gnu.org, Noam Postavsky Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.161253747016855 (code B ref 31641); Fri, 05 Feb 2021 15:05:02 +0000 Received: (at 31641) by debbugs.gnu.org; 5 Feb 2021 15:04:30 +0000 Received: from localhost ([127.0.0.1]:44490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l82er-0004Nm-Rj for submit@debbugs.gnu.org; Fri, 05 Feb 2021 10:04:30 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l82eq-0004NY-3u for 31641@debbugs.gnu.org; Fri, 05 Feb 2021 10:04:28 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6860C440A41; Fri, 5 Feb 2021 10:04:22 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 49EE2440A04; Fri, 5 Feb 2021 10:03:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612537435; bh=SaPTXj2hVxMyXdHCi2i5S1LPEmH2/VK9HNTetZqbLEk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=VVJ/uWzkdVbRcwvJdPLf1f2JB8SHfA5Xbi5Vr34iR7cQOQbpoO7ZzhPpBffue433P hD6TQQli3BlJwCXstA9x48mGt+YNUK5gWflh2yhmDZUZsoB2SmTNaLo52p6szVlxRi HSZrmI6Thy8pxM1Gc4Zbv32p9YOkZLXG174kNn1/Utjr361AO6j+lTcC2yw8nvLITE lh3a0JnJH0AVm4jlvdbkdzltUEqoNKOO9OVNzM5fFftreCOblTNb9dT271MbNNRKUO 4F0DddxJATekqYlkmlcz11Cw3vqw8eJCczs5QcQXx3coAVzw7+7vzH69X32sTqPZ17 4Hn32iV9grCgg== Received: from alfajor (76-10-182-85.dsl.teksavvy.com [76.10.182.85]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0E8671203FF; Fri, 5 Feb 2021 10:03:55 -0500 (EST) From: Stefan Monnier Message-ID: References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> <875z36nbex.fsf@gnus.org> Date: Fri, 05 Feb 2021 10:03:53 -0500 In-Reply-To: <875z36nbex.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 05 Feb 2021 09:53:10 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.086 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > If I'm reading that correctly, that does seem like more obvious > semantics, but is it too late to change this now? I'm not sure how much > generator.el is used in the wild yet... The change in semantics is fairly subtle (e.g. Common-Lisp allows both choices for the similar choice of behavior in `dotimes` and `dolist`), so it's rather unlikely to break existing code, IMO (and I think the likelihood would be higher if the change were in the other direction). Stefan From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Feb 2021 17:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Lars Ingebrigtsen Cc: Christopher Wellons , 31641@debbugs.gnu.org, Noam Postavsky , Stefan Monnier Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.161254514628978 (code B ref 31641); Fri, 05 Feb 2021 17:13:02 +0000 Received: (at 31641) by debbugs.gnu.org; 5 Feb 2021 17:12:26 +0000 Received: from localhost ([127.0.0.1]:44622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l84eg-0007XK-A3 for submit@debbugs.gnu.org; Fri, 05 Feb 2021 12:12:26 -0500 Received: from mail-wm1-f42.google.com ([209.85.128.42]:55607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l84ed-0007X0-UW for 31641@debbugs.gnu.org; Fri, 05 Feb 2021 12:12:24 -0500 Received: by mail-wm1-f42.google.com with SMTP id f16so6584895wmq.5 for <31641@debbugs.gnu.org>; Fri, 05 Feb 2021 09:12:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=T6sVwKYfm3q8O49JW4H7whYl3FdjNS/ApXZexUSpQr0=; b=lvcDN7f4aqrFg0si941CwatflhEVcBgkBudEBTbpLiGu8bm6+5tM3V65o+TmUyZ8cq 9wWKwv2TPDvn74W5b+xTS/PhC6Mg/vN+27MgCySQ/eTsnYYHGW5eDt4Xa8NzGoYZ0Z9h uoM2SWNXNANle0+UnAfhwWTqGRKS49uQ0NuQh+Va3ohC01fLxRG2e5EueBcsQVx8wICG Y8ecVv2r3fGu1P/E5dqAnE0viA83qrQz1WsPfOYgCI3fXNVXeL/lTMr82Z5w+9zA38gQ a6P+RM+gdy6A41Yuw3DGlG+WI3hpHs4KOQP4O+ToJcq/Uii7hmQnhgZV378rNqopvlbb 3X2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=T6sVwKYfm3q8O49JW4H7whYl3FdjNS/ApXZexUSpQr0=; b=iJeHoKoCTWH+LJYSv79eW5M/ecuF2ClFD9TdRRF2nRss7y7Yko+0Z3Da+txKX/1Kgp VWhAHz1fRTT4dDHBI05q8s27EqYk1JLGtHhY39zml0va2lIq8n9RIl+pHrfHTfmMdnB3 5N3NAXvuVZELV1NlaJJaaBSVboh0Su+xlKZjthdYyMLmN1rNvtW5cVmwZwGnVIOGAO1p dpbQL3WN6a/eqCztkzv73nlV242wB/mp1wsMz05dlhvJ5DIySN1roSZ2LQlEUEKSfHRr qPGDPq2TLP6hDtli5ToK3eRMFXu/RbYPdsCRIY/TiV4c3vyjUl3Zpyr42jFcMbNe1bUa LL/A== X-Gm-Message-State: AOAM531T8zOiOda9fXvxIp0iBYkBZoxSuceyVL6WvnhDP/DAdEoOMEqF b5W0Ps9LDTkNYKoNQa8leTGnCg== X-Google-Smtp-Source: ABdhPJy8g236GMlZU4i6UiSUwVoAd7XZf35h44yDneAOu1/GyCQuK12R7GQg49NRIWMlwos+S0BEfQ== X-Received: by 2002:a7b:c21a:: with SMTP id x26mr4469435wmi.50.1612545138096; Fri, 05 Feb 2021 09:12:18 -0800 (PST) Received: from localhost ([64.43.144.22]) by smtp.gmail.com with ESMTPSA id i8sm13807807wry.90.2021.02.05.09.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 09:12:17 -0800 (PST) From: "Basil L. Contovounesios" References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> Date: Fri, 05 Feb 2021 17:12:15 +0000 In-Reply-To: <87czxgtafv.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 04 Feb 2021 11:05:24 +0100") Message-ID: <87mtwi8mmo.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el > index 9eb6d95964..0b644cc72c 100644 > --- a/lisp/emacs-lisp/generator.el > +++ b/lisp/emacs-lisp/generator.el > @@ -731,7 +731,10 @@ iter-do > (,it-symbol ,iterator)) > (while (not ,done-symbol) > (condition-case ,condition-symbol > - (setf ,var (iter-next ,it-symbol)) > + ;; Variables that start with an underscore shouldn't be set. > + ,(if (string-match-p "\\`_" (symbol-name var)) > + nil > + `(setf ,var (iter-next ,it-symbol))) Nit - AKA the following? ,(unless (string-prefix-p "_" (symbol-name var)) `(setf ,var (iter-next ,it-symbol))) -- Basil From unknown Tue Jun 24 15:44:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31641: 26.1; iter-do variable not left unused warning Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Feb 2021 10:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed To: Stefan Monnier Cc: Christopher Wellons , Daniel Colascione , 31641@debbugs.gnu.org, Noam Postavsky Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.16126075321197 (code B ref 31641); Sat, 06 Feb 2021 10:33:01 +0000 Received: (at 31641) by debbugs.gnu.org; 6 Feb 2021 10:32:12 +0000 Received: from localhost ([127.0.0.1]:45102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8Kst-0000JE-Qp for submit@debbugs.gnu.org; Sat, 06 Feb 2021 05:32:12 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8Ksr-0000Iz-5d for 31641@debbugs.gnu.org; Sat, 06 Feb 2021 05:32:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=k1HbUEcHC2YBf765mFFBi0x+8CaLkF5i4jNrV6K9XYk=; b=bj3c8CUmQDANyUhs9dat7I115Q ne5XdZTFWULm7wLEwZp4HtlbK6gwvX2vNoYPd2E8pQ356lq3MFWGD4zDaS46SwOcFJBAtyaqv2VXR 6OBACMi+4CKwxLYeM8iT0FYvzc4OcWQtbLAX4QTkEMRFFdHpKvdHI01KikoPvb93+mXM=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8KsY-0004Rx-O3; Sat, 06 Feb 2021 11:32:01 +0100 From: Lars Ingebrigtsen References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> X-Now-Playing: The Watersons's _Frost and Fire_: "Wassail Song" Date: Sat, 06 Feb 2021 11:31:49 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 04 Feb 2021 11:36:27 -0500") Message-ID: <87mtwhebca.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: > You can clean up this semantics and the warning at the same time by > using an expansion like: > > (let (#3=#:iter-do-result11 > (#1=#:iter-do-iterator-done8 nil) > (#2=#:iter-do-iterator10 i)) > (w [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > You can clean up this semantics and the warning at the same time by > using an expansion like: > > (let (#3=#:iter-do-result11 > (#1=#:iter-do-iterator-done8 nil) > (#2=#:iter-do-iterator10 i)) > (while (not #1#) > (let ((_ (condition-case #4=#:iter-do-condition9 > (iter-next #2#) > (iter-end-of-sequence > (setf #3# (cdr #4#)) > (setf #1# t))) > (unless #1# [BODY]) > #3#) So I tried this... diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 9eb6d95964..dfd2513350 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -725,17 +725,18 @@ iter-do (condition-symbol (cps--gensym "iter-do-condition")) (it-symbol (cps--gensym "iter-do-iterator")) (result-symbol (cps--gensym "iter-do-result"))) - `(let (,var - ,result-symbol + `(let (,result-symbol (,done-symbol nil) (,it-symbol ,iterator)) (while (not ,done-symbol) - (condition-case ,condition-symbol - (setf ,var (iter-next ,it-symbol)) - (iter-end-of-sequence - (setf ,result-symbol (cdr ,condition-symbol)) - (setf ,done-symbol t))) - (unless ,done-symbol ,@body)) + (let ((,var + (condition-case ,condition-symbol + (iter-next ,it-symbol) + (iter-end-of-sequence + (setf ,result-symbol (cdr ,condition-symbol)) + (setf ,done-symbol t))))) + (unless ,done-symbol + ,@body))) ,result-symbol))) (defvar cl--loop-args) But then this fails: 1 unexpected results: FAILED iter-lambda-variable-shadowing Uhm... oh, it fails even without that change? ... If I just say "make check", then it doesn't fail, but if I say "make generator-tests", then it fails? Very odd. > BTW, I think we can remove the duplicate #1 test by moving the body of > the `while` into its test, e.g.: > > (let (#3=#:iter-do-result11 > (#1=#:iter-do-iterator-done8 nil) > (#2=#:iter-do-iterator10 i)) > (while > (let ((_ (condition-case #4=#:iter-do-condition9 > (iter-next #2#) > (iter-end-of-sequence > (setf #3# (cdr #4#)) > (setf #1# t))))) > (unless #1# > [BODY] > t))) > #3#) Indeed. I've now pushed something like this to Emacs 28. > It's too bad that [BODY] can throw `iter-end-of-sequence`, since > otherwise we could move the `condition-case` outside of the loop and get > something more efficient. Yup. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 06 05:32:14 2021 Received: (at control) by debbugs.gnu.org; 6 Feb 2021 10:32:14 +0000 Received: from localhost ([127.0.0.1]:45105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8Ksw-0000JS-4Y for submit@debbugs.gnu.org; Sat, 06 Feb 2021 05:32:14 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8Ksv-0000J4-83 for control@debbugs.gnu.org; Sat, 06 Feb 2021 05:32:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lIa8A+4A8+/yHzMPTuRJRccsUaspnOc+r9kYlvm9I9Y=; b=PeIgI6zTkXlY/gYueJBe9UguuS aqxCG1/H+Y5rKeApaEOktjEhYmUb9s0rUTCYE8GQNLKhyAICCLRRb5wS3Lx7J5AX6BcbOkbnn3uPA EQrcmmYosrKZrPF0/DCgM+z6QkQYR5Z4V4cp8CVt7nIPC9dVUcJnvSyK0ZsnqJYbRA5Q=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8Ksn-0004S7-FD for control@debbugs.gnu.org; Sat, 06 Feb 2021 11:32:07 +0100 Date: Sat, 06 Feb 2021 11:32:04 +0100 Message-Id: <87lfc1ebbv.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #31641 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 31641 fixed close 31641 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 31641 fixed close 31641 28.1 quit