From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Why is lexical-binding's global value ignored? Date: Mon, 30 Jan 2023 21:45:25 +0800 Message-ID: <87cz6wyw3u.fsf@yahoo.com> References: <25094a24f891856fe0757fa34d80017b@bitrot.link> <83bkmh96gc.fsf@gnu.org> <43216edcfeada34083e17a8230af2ee3@bitrot.link> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14379"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: abq@bitrot.link Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 30 14:45:57 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pMUTt-0003bM-1F for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Jan 2023 14:45:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUTf-00022n-VV; Mon, 30 Jan 2023 08:45:43 -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 1pMUTd-00022d-11 for emacs-devel@gnu.org; Mon, 30 Jan 2023 08:45:42 -0500 Original-Received: from sonic302-21.consmr.mail.ne1.yahoo.com ([66.163.186.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUTb-0002yo-CU for emacs-devel@gnu.org; Mon, 30 Jan 2023 08:45:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675086337; bh=fZD/UVotEP6hxDtnQn7X9Bs0iS281VUuT2K3oSsmQSs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=TMfBxr116hc2XIC08djQZVgUOFxJqq6EzRSzuQs0JvjfqymP9INYWIVbJn2kDFz/6GQKH47pfH8zESm977QxUseBU9nB6SkskdJingzoHMH//1AyPT6JW2txO44zh7eIZ1APeAvCIM7lj2kne3ERBYqCWFx6WuWDKMKByuoZwrc4DUyYHyYUQy0f+ZFu+QRcgel1GhphqEYYMAtcajdzpviXbVUrsJiE0P4yfve2Rk0OiKXN2Xw5v+H4o09iqjsGhKkS1AgMiXUlGEtphyFDpfvbGVJvSCizg9NnkGcBl+LGhONlUqACahafoC9HEWDLNe6/SVIZZnffH6aiL8c/Uw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675086337; bh=oj62ax6R0IXKezvQTav3PYuoC32tADYi7Ae4+qWhoLt=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=mZndjcpTaYN2ySSwXm3CBBG6+tqCT459L0BP4XgTPL3G03ulzNmjt7Fxe+yO+F9YnxtBVQKZjUplBfTMveXd+KLLDjAqBrjEtofozro1uzGAPhO/rQFkg0eIkIVMxl5Ipzl8F8j1DnG6j2muAObxmrVH7MonyQMRUe0A1Qy/UprFTHhktCG76WUlbSjwR+El6gYIlroZ8JrT9irLsL/3zzaiW23Jq5hO4Zwj7vBa0EsZwvpfIPfW2vQyEV2Shl3fQEQcve99tdKXXiJQO0AMl0Y0OJMKPdDBgtLhO7+klgEuWTyGsqO8ZnVb23Aob58DJEWsbleycS9wOzY6YlUhLg== X-YMail-OSG: TvOkMqIVM1mv6oCgXrFoYmFxP2KMY8rbjtHnBxJA86n2U89HZYe1p9H08d.gNhG 3S8aR9s5mV_Y67xZ5L9E5RHvTdJN6_mxOqLJIVEo9aCHDmUbzViOzWSHjGqKMZTNgHfxkRejSIMl IfcqsMUIOp222Cs8y.f95wGbmPBiYyrpR0EiGBJJ95b8jCG6ImzkS8L7qTz3p7MEJrtJX3R9py23 TMfODxtgzORqLtWPQzYZjh7oIsW.mZrMqRio.wnEQijhjwEbOwmnGpDJTX22woIbP6iel7umw4xt 2qbbwYadYWOtfO.s92ALctSdgJQlMJ6WU6rgN5s1vncBfZUUGF9rxvIW75_RgxwQGd3URZwzouWs uZR7qnHKIrSRW18E0UnA2ikauzLNtWbabsehRtuzYUUaEvXfaR7kv32MW5j7DQ84d8_W29yBwPse XR0URixLCS81d0lw7nF2Qxsogq3S1hbZBqNp3ohgAEwx1BYdR5hBAWbLNQDLgLSYp2tL9aw8QNXg JoMInwSEtTniC4lDjc1mI9Hp275m4V_RhJn9zmNIgXxt1rAe8KPIamuv.t4uxAY5aiS8R1JPF7V0 23Wt.pL2gyJ.iRlfmbwuQFvcYMVdN_p7gzlfwqMMmrcC_lKvlZqZRcxpf1bEugNaN7Jn61Fbbvi0 0RGvrxBB31E3p5j6XvUGYg.Ny75D74MQ.voBm7zREWBBURAcVnI1Dzd6sZHSIyNeHzBWpkfLuclR IYVKigaKSqJ.JcoLt2Pz5bO63YUXj.CCuIiaUIdRGiijMr6nZW_MVvsDx9VGSJfEU1wc6MkaGGJK sygITS2eNkkZS8X2ktti1YRIGJBAegPX8JoIERL0Av X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Mon, 30 Jan 2023 13:45:37 +0000 Original-Received: by hermes--production-sg3-9fc5746c8-r2vxw (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 57131ffc27bb6c6f51d8f2eea28260d0; Mon, 30 Jan 2023 13:45:31 +0000 (UTC) In-Reply-To: <43216edcfeada34083e17a8230af2ee3@bitrot.link> (abq@bitrot.link's message of "Sun, 29 Jan 2023 20:53:30 -0700") X-Mailer: WebService/1.1.21123 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.186.147; envelope-from=luangruo@yahoo.com; helo=sonic302-21.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302782 Archived-At: abq@bitrot.link writes: > Then it breaks! As I wrote in my response to tomas: =E2=80=9CIn order to = break > anything, you would have to do so explicitly, via (setq-default > lexical-binding t).=E2=80=9D > > Of course, nobody actually does that. Therefore, it would be safe to > honor the global value in Emacs 29. > > And the reason nobody sets the global value is that currently it would > be pointless, because it isn't honored in Emacs 24 through 28. > > There's no danger of anybody accidentally setting it with plain setq, > since it automatically becomes buffer local when set. You have to > purposefully shoot yourself in the foot with setq-default. [...] > But of course, dynamic binding isn't always used intentionally. It's > also often used in cases where the programmer gave no consideration to > the difference (and often, unconsciously intended lexical > binding). Since the longstanding, widespread computer science > consensus is to program using lexical binding except in special cases > where dynamic binding is intentionally chosen, it's sensible to > facilitate a bias in that direction, at least optionally. > > If you use lots of historical code written with no consideration of > the difference, one way to test the code would be to sprinkle > lexical-binding: t across the tops of all your files, and keep track > of which ones have it set because they actually expect it vs. which > ones have it set just so you can test them. Which, ironically, is a > bit like using a purely functional language with no dynamic binding or > global variables, so you're forced to modify all your function > signatures and calls to explicitly pass global state as an argument. > > Or, a more sensible way to test your historical code would be to > simply do (setq-default lexical-binding t) in your init file. But you > can't do that in Emacs 24 through 28, because the global value is > ignored. > > If it were honored in Emacs 29, then a news item could be added, > suggesting everybody try (setq-default lexical-binding t) in the init > file, to test all the packages they use, then add explicit > lexical-binding: nil (or defvar) in the cases where dynamic binding is > intentional. People who think this is nonsense can harmlessly ignore > the suggestion. And why would you want to break it? I think most of Drew Adam's packages do not use lexical binding. Neither does much of the code which comes with other GNU software, such as the major mode GMP provides to edit its special assembler macros. We must not deliberately break such software!