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:09:36 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000007ed83d06095fe8f1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30363"; 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:10:47 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 1qzUTF-0007ll-EP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Nov 2023 05:10:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzUSy-0004kY-R4; Sun, 05 Nov 2023 00:10:28 -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 1qzUSv-0004kI-EI for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:10:25 -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 1qzUSv-0006HP-5x for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:10:25 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qzUTV-0002Qe-Ll for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:11:01 -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:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 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.16991574359294 (code B ref -1); Sun, 05 Nov 2023 04:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Nov 2023 04:10:35 +0000 Original-Received: from localhost ([127.0.0.1]:35947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzUT5-0002Pq-3J for submit@debbugs.gnu.org; Sun, 05 Nov 2023 00:10:35 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:60612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzUT2-0002PZ-HE for submit@debbugs.gnu.org; Sun, 05 Nov 2023 00:10:33 -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 1qzUSM-0004iY-K1 for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:09:50 -0400 Original-Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qzUSK-0005yH-Vn for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 00:09:50 -0400 Original-Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7a956887c20so139337739f.1 for ; Sat, 04 Nov 2023 21:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699157387; x=1699762187; darn=gnu.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=F91Ejp7eyRQPFauVvgZ9xNlED1FssMUdBVhpifQL7k8=; b=D/plaodn4sEbXsZ+rxJmYzQ+wyZYa2pxa/jppr9XH/ypHcyDSsdlmv7UecLTHz11qL 05v/j3eHTANqpMxm3YLfrhwaEOGiC6KfV38PHdqr0/NxZtJ94n1vyFHZXYn11dApNTS0 K9Ute3D38UPQTETvcv1u9e8zhNbjbs+L97BeKUsv5Ut2Xek5rQgOJYXsmfV7rPBykyoJ 4pIJIVM7wKdBU3DeBimEwn5z+NEggEkrPQ/nFGHbRb77h8zR/sWZwG1fV3dzZ2YaS4h/ UIgv1YKQfOQObcYMGljaKAQJqX6XDqPw+zSzfgiToLl779rczy0k1lbLUneHjGT/uXwU kXFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699157387; x=1699762187; h=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=F91Ejp7eyRQPFauVvgZ9xNlED1FssMUdBVhpifQL7k8=; b=izebI29u7L94uzBZGUNvsXu5yEJrcD29LjEbgCQCPunsi/BiCQl/gJxk5mp1MqDUXf dPW906UiXnTCX6bl1UMO1f9Jwjxnbs/cSsbLx7CSrZC0SWUA5depi9WgEqwwWvyNKJDP eFSC9tnBBdoHaRTx56PN8/gi9Z7hj0z/8cTzXq6DDdQa75DsPFTknMEBDK4hihNeV3Ox CtVpGaYmQCDi1Yut8p4cVOsoaRxE8YA+bdOHv5TDHRowmDN+VjfcdyVXh+sDSWk+wL4m vxRs/8IEzABNWe7+PjgQWxmpUs5IMyOGW5GObY+RTHaTDr0quW/caB8XKYvzvi+2jJTJ g4yA== X-Gm-Message-State: AOJu0Yz6sPaG4flpXa6ziebCQy29ixUwxy9e6c4+2HrVGALlsNcsosLx ECkkV5WqeJwnkH9hwemClC65AxgldosvQoX/lvHxSKAz X-Google-Smtp-Source: AGHT+IFfW4IC385i9l0EFjoVUrbxjZW8My1/HL+xTGGq1dEosb6wu/n8wW+iUn6+UALt1s56hGl9DdMwIL022FZUemM= X-Received: by 2002:a92:c541:0:b0:351:e70:2cec with SMTP id a1-20020a92c541000000b003510e702cecmr33041538ilj.20.1699157387432; Sat, 04 Nov 2023 21:09:47 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::d2c; envelope-from=deego3@gmail.com; helo=mail-io1-xd2c.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:273798 Archived-At: --0000000000007ed83d06095fe8f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I apologize.I meant to say it should print 0 to 10 the first time around because ,ii should hardcode the value at the time of macro definition. But, the second and third time are so absolutely weird? On Sun, Nov 5, 2023 at 12:06=E2=80=AFAM Dave Goel wrote: > 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 cod= e > 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 va= r.* > I reproduced that as well. > > Dave > > > --0000000000007ed83d06095fe8f1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I apologize.I meant to say it should print 0= to 10 the first time around because ,ii should hardcode the value at the t= ime of macro definition.=C2=A0=C2=A0
But, the second and= third time are so absolutely weird?



On Sun, Nov 5, 2023 at 12:06=E2=80=AFAM Dave Goel <deego3@gmail.com> wrote:
I was playing around, checking my sanity re : dynamic = scoping.=C2=A0=C2=A0I'm probably rusty, but I could swear that on older= emacsen, this sort of code would print 33 ten times.=C2=A0


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


(progn
=C2=A0 (setq l= exical-binding nil)

=C2=A0 (dotimes (ii 10)
=C2=A0 =C2=A0 (defmac= ro 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_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 )))

Exits without er= ror 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.=C2= =A0
Let's evaluate it a third time! The third time is even weird= er.
The third time, it complains
Deb= ugger entered--Lisp error: (void-variable ii)
=C2=A0 (list 'message = "%S" ii)
=C2=A0 (lambda nil (list 'message "%S" = ii) (list 'print ii) (sit-for 0.1))()
=C2=A0 macroexpand((mac) nil)<= br>=C2=A0 macroexp-macroexpand((mac) nil)
=C2=A0 macroexp--expand-all((m= ac))
=C2=A0 macroexp--all-forms(((setq ii 33) (mac) (setq ii old_ii)))=C2=A0 macroexp--expand-all((let ((old_ii ii)) (setq ii 33) (mac) (setq i= i old_ii)))

and so on.


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

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

Dave


--0000000000007ed83d06095fe8f1--