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 00:06:49 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000092152706095fdef2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17657"; mail-complaints-to="usenet@ciao.gmane.io" To: 66940@debbugs.gnu.org, deego3@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 05 05:07:57 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 1qzUQX-0004TP-88 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Nov 2023 05:07:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzUQA-0004JU-0i; Sun, 05 Nov 2023 00:07:34 -0400 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 1qzUQ4-0004JH-Fq for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:07:29 -0400 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 1qzUQ2-0005jG-BH for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:07:26 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qzUQc-0002LZ-F3 for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:08:02 -0400 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 04:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66940 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org, Dave Goel Original-Received: via spool by submit@debbugs.gnu.org id=B.16991572789009 (code B ref -1); Sun, 05 Nov 2023 04:08:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Nov 2023 04:07:58 +0000 Original-Received: from localhost ([127.0.0.1]:35942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzUQY-0002LE-C3 for submit@debbugs.gnu.org; Sun, 05 Nov 2023 00:07:58 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:35012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzUQU-0002Kw-9l for submit@debbugs.gnu.org; Sun, 05 Nov 2023 00:07:55 -0400 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 1qzUPg-0004IH-8v for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:07:07 -0400 Original-Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qzUPe-0005il-Nt for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:07:04 -0400 Original-Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3594cb642beso13097845ab.3 for ; Sat, 04 Nov 2023 21:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699157221; x=1699762021; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=EKjfXIgQdpCly68E+BvvimVXE/ceu4w0ynNtFC8cxXU=; b=OH45708m+xz3wUv+grLWyVJgVuxcLmRAKm/gth+6+9nl1K+ssB1g+z5+F4sltA7SFL UIvGbrmzRf+0ckjuSb4Ne0iA53Mfo/JuVcLPQaXsqodAOTYKPWl12S3tn1D6kOEZwrgQ X94iRHkwtXEI4TA4OEbToLRcq9zAmWIGrdC8lmYTiJmu7mBNY2I98jCC0Q1SPG8PAh++ mNJFDMmVCDMt2fDPjFcB74AmhEKQsKVjs3sTSRJwEJfVG8oA9Z5SuU6Ek+v9JDAOWsTJ 8Ljpr/RKOSBt70g9KHREJ05cc5Wkn3+AhhtO3j1aJ6J3ffrKdE2TZAh8fJ/AeB0FAK4s ITSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699157221; x=1699762021; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EKjfXIgQdpCly68E+BvvimVXE/ceu4w0ynNtFC8cxXU=; b=MsfXYkVmPUE8IPGS4n1CdEhpTAQXtF7iInog3XhuE17QhmrbOSZiTIk5GNESbCTboc THmHl4LPZ/Bp/anjNlWGxQF1oVUMnMb6genaOCcU1aBIe8KvK2wgH6sFq/Rv35sL/xP6 AyWy6+vCeMh93R7423gDdfUjedzYLZLnX0ClYNtuzpDwavI2vVuLk715ptC7BGSaqNTj lJ+WleZlbY4McHUgMP6q3p6HEhy73ETV41kY99tbtpWAK1bwl1BgVBVWtfYjQlQnixdQ /vD7J2IKvzzSAKRVoDAqSq8YvgGGIfsXbRiRtuSYtEWWCKWKdVUS7D2qjpCMszo+a5WA Tprw== X-Gm-Message-State: AOJu0YwuPeH8lSodB641tOsCwnbI5yaO8pyQnLLRZJl5Qz7IQMv/4jLd xcIVS3QflvofSNeWvCY8u59o5fazsW5KuoNKTZIrjH50xLE= X-Google-Smtp-Source: AGHT+IFHwC39udr20nFWura46d0WUWlVmmFZnbPW30+USqvK5KPujuzVVjPtgTNipBNwiSOFSl0StUAV5LSJ7bQDH5Q= X-Received: by 2002:a92:c566:0:b0:359:6a34:904d with SMTP id b6-20020a92c566000000b003596a34904dmr7111321ilj.3.1699157220920; Sat, 04 Nov 2023 21:07:00 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::12d; envelope-from=deego3@gmail.com; helo=mail-il1-x12d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273797 Archived-At: --00000000000092152706095fdef2 Content-Type: text/plain; charset="UTF-8" I was playing around, checking my sanity re : dynamic scoping. I'm probably rusty, but I could swear that on older emacsen, this sort of code would print 33 ten times. On emacs -Q with debian stable (28.2). I try this (progn (setq lexical-binding nil) (dotimes (ii 10) (defmacro mac () `(message "%S" ,ii) (sit-for 0.1)) (let ((old_ii ii)) (setq ii 33) (mac) (setq ii old_ii) ))) Exits without error the first two times, although, strangely, i don't see any messages the second time. (I expected to see ten 33's). *(a) As in, the second time, it doesn't print 33 ten times, as we would expect.* *(b) The third time is stranger. * Let's evaluate it a third time! The third time is even weirder. The third time, it complains Debugger entered--Lisp error: (void-variable ii) (list 'message "%S" ii) (lambda nil (list 'message "%S" ii) (list 'print ii) (sit-for 0.1))() macroexpand((mac) nil) macroexp-macroexpand((mac) nil) macroexp--expand-all((mac)) macroexp--all-forms(((setq ii 33) (mac) (setq ii old_ii))) macroexp--expand-all((let ((old_ii ii)) (setq ii 33) (mac) (setq ii old_ii))) and so on. The bug(?) was reproduced on 29.1 as well - by e1f on #emacs *(c) It gets even funnier. e1f changed ii to var, but the third time, it still complained about ii, with the above error message, and not about var.* I reproduced that as well. Dave --00000000000092152706095fdef2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I was playing around, checking my sanity re = : dynamic scoping.=C2=A0=C2=A0I'm probably rusty, but I could swear tha= t on older emacsen, this sort of code would print 33 ten times.=C2=A0
=


On emacs -Q with debian stable (2= 8.2).
I try this


(progn <= br>=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)
=C2=A0 =C2=A0 =C2=A0 (sit-for 0.1))
=C2=A0 =C2=A0 (let ((old_i= i 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 )))

= Exits without error the first two times, although, strangely, i don't s= ee any messages the second time. (I expected to see ten 33's).

(a) As in, the second time, it doesn't print 33 ten t= imes, as we would expect.

(b) The third time is stranger.=C2= =A0
Let's evaluate it a third time! The third time is even weird= er.
The third time, it complains
Debugger entered--Li= sp error: (void-variable ii)
=C2=A0 (list 'message "%S" ii= )
=C2=A0 (lambda nil (list 'message "%S" ii) (list 'pr= int ii) (sit-for 0.1))()
=C2=A0 macroexpand((mac) nil)
=C2=A0 macroex= p-macroexpand((mac) nil)
=C2=A0 macroexp--expand-all((mac))
=C2=A0 ma= croexp--all-forms(((setq ii 33) (mac) (setq ii old_ii)))
=C2=A0 macroexp= --expand-all((let ((old_ii ii)) (setq ii 33) (mac) (setq ii old_ii)))
and so on.


The bug(?) was = reproduced on 29.1 as well - by e1f on #emacs

(c) It gets even funnier. e1f changed ii to var, but the third time, it st= ill complained about ii, with the above error message, and not about var.=C2=A0 I reproduced that as well.

Dave


=
--00000000000092152706095fdef2--