From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#31641: 26.1; iter-do variable not left unused warning Date: Sat, 06 Feb 2021 11:31:49 +0100 Message-ID: <87mtwhebca.fsf@gnus.org> References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> <87czxgtafv.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29000"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Christopher Wellons , 31641@debbugs.gnu.org, Noam Postavsky To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 06 11:33:11 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 1l8Ktr-0007RF-Qq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Feb 2021 11:33:11 +0100 Original-Received: from localhost ([::1]:37358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8Ktq-00062M-IJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Feb 2021 05:33:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8Kti-000628-AS for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 05:33:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8Kti-0004jj-3H for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 05:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l8Kth-0000KU-VL for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 05:33:01 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.16126075321197 (code B ref 31641); Sat, 06 Feb 2021 10:33:01 +0000 Original-Received: (at 31641) by debbugs.gnu.org; 6 Feb 2021 10:32:12 +0000 Original-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 Original-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=; Original-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 X-Now-Playing: The Watersons's _Frost and Fire_: "Wassail Song" In-Reply-To: (Stefan Monnier's message of "Thu, 04 Feb 2021 11:36:27 -0500") 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:199407 Archived-At: 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