From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dave Goel Newsgroups: gmane.emacs.bugs Subject: bug#66940: Dynamic scoping is all weird now? Date: Sun, 5 Nov 2023 14:07:02 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fc5ff006096c7152" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3683"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66940@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 05 20:07:50 2023 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 1qziTO-0000qu-18 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Nov 2023 20:07:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qziT0-00018B-UN; Sun, 05 Nov 2023 14:07:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qziT0-000183-41 for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 14:07:26 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qziSz-0008FU-Rp for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 14:07:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qziTa-00049h-GN for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 14:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dave Goel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Nov 2023 19:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66940 X-GNU-PR-Package: emacs Original-Received: via spool by 66940-submit@debbugs.gnu.org id=B66940.169921127915964 (code B ref 66940); Sun, 05 Nov 2023 19:08:02 +0000 Original-Received: (at 66940) by debbugs.gnu.org; 5 Nov 2023 19:07:59 +0000 Original-Received: from localhost ([127.0.0.1]:38233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qziTX-00049Q-DB for submit@debbugs.gnu.org; Sun, 05 Nov 2023 14:07:59 -0500 Original-Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]:53302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qziTU-000498-EJ for 66940@debbugs.gnu.org; Sun, 05 Nov 2023 14:07:57 -0500 Original-Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-35742cbb670so15289555ab.2 for <66940@debbugs.gnu.org>; Sun, 05 Nov 2023 11:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699211234; x=1699816034; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FFWstyAuJ5TW6otKw5dN7Hof5Y+EzffBZ4aoLhSnMU8=; b=XDM9FAk4wMDvHfMrWus50/2ZSwfoWSLdH4N3q9XHaRGgmASiSN6iJ6R4Cv+ij+t6Sx dJhcmK+uhuujUa+HI4GRUzOo3uCVqPx82S4qeU3i9cs4IpuLvBEg4MQhvjOzOkVzj2FB kTpI+RPoUp7HNAeBThLPchx2DL1oq1wo9R/WzhdNVlKOHfTJcb9dyRC4vA7SehxgRvHf J2iLSkOV7pC/mg9M1L3h4g2R/vLem1Vx9oBvQKASZsr205n8e1n9YwIC7/HSdeq/7T6K yHHlpPU0YjvbsrixlzTbkKosLb2YKw83AamJ+I3oDXjxaHDNT17vRFII0bdrsfAaU44J 4PEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699211234; x=1699816034; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FFWstyAuJ5TW6otKw5dN7Hof5Y+EzffBZ4aoLhSnMU8=; b=Rsy3VZPleJPza7uMhk7J5wjISEJSFQKeZOxIEIu9EZFgwgAhT1vmuYj93opiCx7TR2 F4uRvrj3HvSQGySWdo1h4+DX5yYNaxuE6Ff29dzqm5duI7Xqo3I6rnBfRApsjF3eJ99d VspjPo2kUZBkDmo4e2lZWwREMZusXRqopoJq1JvFaNBNqRs8uqc4fZojP2wNCc9x2O50 WC1qAb9iFs83d9nuG+N50qdHbo8GomcOHlvwewFGx5qy0PEI52mqKfH65arqLaSr8SXA 6DZV/9WYUA/XFkHoP+Rp1SoeZjFRoLNqQ60MwtWMlRmVgcpSUD3VfhRlRl+UYoDal6E4 t/Mg== X-Gm-Message-State: AOJu0Yx7tYdWT3hWKepl3iyOdUUNMX4R8nxUNpzNrnJEjTguYqg6yink Pj4v7zj9DkJEuAUeUxexuAtwRhFbPhwDcfQmGIw= X-Google-Smtp-Source: AGHT+IHgFaoggal1xTrVxgNKNMx2HLdttVE3UvHd0nrBI0tFDeiCHnhX4QfOKvoCWqUT/KaxKulNsSmC545hgvs4+6s= X-Received: by 2002:a05:6e02:12c6:b0:351:22a2:bbe7 with SMTP id i6-20020a056e0212c600b0035122a2bbe7mr34320117ilm.0.1699211233745; Sun, 05 Nov 2023 11:07:13 -0800 (PST) In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273841 Archived-At: --000000000000fc5ff006096c7152 Content-Type: text/plain; charset="UTF-8" Gerd, Ok. I hope this bugreport is clearer - Here's some code. The variable ii is clearly set every time mac was defined OR called. backquote should expand, and mac should have read its content as (list 'message "%S" ii). (progn (setq lexical-binding nil) (dotimes (ii 10) (defmacro mac () `(message "%S" ,ii) ) (let ((old_ii ii)) (setq ii 33) (mac) (setq ii old_ii) ))) You eval this code once. It works. You eval this again. It works. The third time, though, it lands you in the debugger. The very same code. Why the third time? And, why the debugger? ii is well set every time it is used. That was bug (b). That's clearly an emacs bug? Here's (c) - The third time, change every "ii" to "var" ,and change every "old_ii" to "old_var". And, evaluate it. We still get the very same error, but the error involves ii, not var. The code we are defining and eval'ing has no "ii" whatsoever. It should have forgotten the old mac that involved ii. We defined a new mac involving "var." > > --000000000000fc5ff006096c7152 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Gerd,
<= br>Ok.

I hope this bugreport is clearer -

Here's some co= de.

The variable ii is clearly set every time mac was defined OR cal= led.

backquote should expand, and mac should have read its content a= s (list 'message "%S" ii).




(progn
=C2= =A0 (setq lexical-binding nil)

=C2=A0 (dotimes (ii 10)
=C2=A0 =C2= =A0 (defmacro mac ()
=C2=A0 =C2=A0 =C2=A0 `(message "%S" ,ii)<= br>=C2=A0 =C2=A0 =C2=A0 )
=C2=A0 =C2=A0 (let
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 ((old_ii ii))
=C2=A0 =C2=A0 =C2=A0 (setq ii 33)
=C2=A0 =C2=A0 = =C2=A0 (mac)
=C2=A0 =C2=A0 =C2=A0 (setq ii old_ii)
=C2=A0 =C2=A0 =C2= =A0 )))


You eval this code once. It works.
You eval this agai= n. It works.
The third time, though, it lands you in the debugger. The v= ery same code. Why the third time? And, why the debugger?=C2=A0 ii is well = set every time it is used.

That was bug (b). That's clearly an e= macs bug?


Here's (c) -

The third time, change every= "ii" to "var" ,and change every "old_ii" to = "old_var".
And, evaluate it.
We still get the very same err= or, but the error involves ii, not var. The code we are defining and eval&#= 39;ing has no "ii" whatsoever. It should have forgotten the old m= ac that involved ii. We defined a new mac involving "var."



--000000000000fc5ff006096c7152--