From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#51982: Erroneous handling of local variables in byte-compiled nested lambdas Date: Wed, 1 Dec 2021 23:32:49 +0100 Message-ID: <6EA55EF4-D5B2-490E-B1FF-DC86A034C893@acm.org> References: <87y25jo2q1.fsf@web.de> <29C3A3F8-CD9F-4AF2-A731-3304FC30E380@acm.org> <87wnl23pnd.fsf@web.de> <59A729EF-C4D4-47EB-9ADC-19FE8EBE7F10@acm.org> <877dd0bi17.fsf@web.de> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1763"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Heerdegen , Paul Pogonyshev , 51982@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 01 23:33:25 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 1msYAH-0000Dj-3s for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Dec 2021 23:33:25 +0100 Original-Received: from localhost ([::1]:36298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msYAF-0001vD-9S for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Dec 2021 17:33:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msY9u-0001uo-7D for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2021 17:33:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1msY9u-0008DR-08 for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2021 17:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1msY9t-0008Uw-Ta for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2021 17:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Dec 2021 22:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51982 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51982-submit@debbugs.gnu.org id=B51982.163839797732656 (code B ref 51982); Wed, 01 Dec 2021 22:33:01 +0000 Original-Received: (at 51982) by debbugs.gnu.org; 1 Dec 2021 22:32:57 +0000 Original-Received: from localhost ([127.0.0.1]:46025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1msY9p-0008Ue-Jp for submit@debbugs.gnu.org; Wed, 01 Dec 2021 17:32:57 -0500 Original-Received: from mail239c50.megamailservers.eu ([91.136.10.249]:46100 helo=mail56c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1msY9n-0008UR-EC for 51982@debbugs.gnu.org; Wed, 01 Dec 2021 17:32:56 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1638397973; bh=LQKYk65KJuyg4hyfr6xgoYanMuCeynhfM5v5ryh5OBk=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=hybuFOA11e4LI21sVww4eAK1fWBWnculRTK09vFzbO4fstddpQ9YtHzobqXPDgk8T 2Gh9nXU+o4PlEzTj3siDGIWWYJL8yHjjYwEhJHB3Z7j3hA37xRSfSse8mCvSNvok0z +kl9xeKHwqH2phzzP3OXc1sAo6+SdJSHBCR1RW28= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-b952e353.032-75-73746f71.bbcust.telenor.se [83.227.82.185]) (authenticated bits=0) by mail56c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 1B1MWoee014055; Wed, 1 Dec 2021 22:32:51 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.21) X-CTCH-RefID: str=0001.0A742F1E.61A7F815.0007, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.4 cv=G/d/r/o5 c=1 sm=1 tr=0 ts=61a7f815 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=DOUPeibL_tSTObFTsK4A:9 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Origin-Country: SE 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:221251 Archived-At: 1 dec. 2021 kl. 19.34 skrev Stefan Monnier : >>> BTW, have you checked the impact on byte-code quality? >> With respect to these patches? >=20 > No I meant w.r.t removing `let*` (or `let` as the case may be). Yes, and I can confirm that both transformations (let* -> let and the = inverse) seem to generate almost or exactly identical bytecode for = lexbind code. If you can find an example where it's worse, I'd like to = know. >>> Also, If mapping is of the form (car-safe SYMBOL) is `var` really = the >>> correct answer? Shouldn't it still be (cadr mapping)? >> Can there ever be a difference? >=20 > There's a big philosophical difference, yes. We could declare it an invariant and add an assertion. > I think another way to do the patch B would be to replace `var` with > `lifted` right when we construct the (apply-partially ...) thingy > (i.e. in the :lambda-candidate part of the function), so those vars = that > get remapped to `internal-get-closed-var` wouldn't even make their way > to `extend`. Yes, that would probably be even cleaner. Then we wouldn't need to worry = about shadowing for those. I'm not going to do more experimenting with it now but do try it if it = makes the code better. By the way, I did try constant-propagating `(internal-get-closed-var N)` = but got less yield than I hoped for. I'll look closer, maybe I made a = silly mistake. >> Good comments, thank you very much! >=20 > [ I resent this implicit suggestion that I could ever write something = less > than a good comment. ] That wasn't for your consumption but to inform the unwashed masses who = can't tell the difference!