From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#74145: 31.0.50; Default lexical-binding to t Date: Thu, 31 Oct 2024 16:31:49 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33339"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Andrea Corallo , monnier@iro.umontreal.ca To: 74145@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 01 00:33:18 2024 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 1t6efF-0008P0-9g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Nov 2024 00:33:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6ef5-0002Nd-Rq; Thu, 31 Oct 2024 19:33:07 -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 1t6ef1-0002NM-FF for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 19:33:03 -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 1t6ef1-00047B-6d for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 19:33:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:MIME-Version:References:In-Reply-To:From:To:Subject; bh=gHZz0WrfstlA3FYHhiB8BCwIzSQ2dRxkmEI7N4iDUFU=; b=IxVZVdn+SdxeLM7fvTAC/wzpP7jz3Gu2YyjYjdXfh1JBrpVRX08PD6fnGAbFKh4iJjt/IO8f97KghBfZAKcU9fpHLeCIwcpJ/dMN8vEWdsEdgvnl+sNRYbuxAhR5S9nZ5w1LtnLcJLlWlNwt3MyEfNwkUGxTEJ8D3vc4wAY1ZbFTL8+xDcRLZJPmB7PaLcSqNDucNiGp1vzDRL59X2/ANwObNJs4fTfrOr9c4J0dZj9qnQHxM6gA8vc38SDjdYpAidhaYrocVnAhsrheZd8DySGRQviDjtpfqwfUpIAYk6l1r0kn0bVP9z8yz8BtalA/AOQd9mHE4Lz+trYWwdbPvQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6ef0-0006fE-IP for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 19:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2024 23:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74145 X-GNU-PR-Package: emacs Original-Received: via spool by 74145-submit@debbugs.gnu.org id=B74145.173041758025609 (code B ref 74145); Thu, 31 Oct 2024 23:33:02 +0000 Original-Received: (at 74145) by debbugs.gnu.org; 31 Oct 2024 23:33:00 +0000 Original-Received: from localhost ([127.0.0.1]:45020 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6eey-0006et-51 for submit@debbugs.gnu.org; Thu, 31 Oct 2024 19:33:00 -0400 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:47376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6eew-0006el-Di for 74145@debbugs.gnu.org; Thu, 31 Oct 2024 19:32:59 -0400 Original-Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5cebcf96fabso53542a12.3 for <74145@debbugs.gnu.org>; Thu, 31 Oct 2024 16:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730417511; x=1731022311; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=gHZz0WrfstlA3FYHhiB8BCwIzSQ2dRxkmEI7N4iDUFU=; b=fwfv92qeUoamfNUuSGtjvGgqYmy4dJRMWI7LrqbKaYVYszr7ZRg1cq8Ql1ehkfFNNG zP5qL5bPLEkHYu8NqDK/ZJoiEKwQP1qlR3Cr3femHGeHUdJrXjpnCrbZrdsxy4pGDl8p T+Kfs+uZc+HNdePGTz3DuNEATsLGAwqI5muHXax/54+HufStA0kylc4Pzt3IyVGFuJeQ ep8NThgmr9RcGPFyiJfpOzXCTFPB0EqkRfNY2Dm+yzaMr4xKGuTYtjC9H2/SjiswvixO 52KRa3DpJCFmoGTr7znAQbLJ3nvgubw4dGOEfaQLBnsCBmPKVY1HSl1AJKXqTXlnMjDQ Bk+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730417511; x=1731022311; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gHZz0WrfstlA3FYHhiB8BCwIzSQ2dRxkmEI7N4iDUFU=; b=XlKKnmtLS+sCt87JwbUHCi+WnvaaGCGosDc2dafQAoh3H1ZeR7uk/3NSlHhexzRjuZ Rzi5HxgdkTBTCZUlnQwmX+oVHY+ppyby9tveuV3caab0UktRVmJXI3uRjtyPUyo/mhi5 LTUb3LiBOTnTUo82yIFFdbypxyt87alqMDGfcLnlSsEXJaB6Q/wTwFwVS2kN8XStAZxm gj5VdW66ZSZxGoD26uyLf6undx8+rzFGho05K6zElHKsEgGyJrNLXs8Ogsldqc9rIf6V f0ChOSK7v0vTYU0YptaRrHolHUOFz3mZOkW+UIMe2BG2qGlpMYVrQ5jMbwt2GCWF4din 4HcA== X-Gm-Message-State: AOJu0YwoLmJ9ohGCHSAW9UYZxj+OtGuNWj4o0B6mJwrCpviI2QrPUExj pxtB6pb5x2c1qZnIybyW5uVXVYXU5nGtHiXm5OYeVO6QmOgq9zGbsnT2qno3dtgS2u2wmWO7PDB kOiaq4nQT4GtD9hyGtIwce1xvUsIAqQ== X-Google-Smtp-Source: AGHT+IGCPeVTUUZMyO7L1IlVh5IRo4Ly852wXoY+b3+UGOqS82k2EME0L6KlMrSJctUSUKlQtx1A7o2DC57qfgIn9cc= X-Received: by 2002:a05:6402:2105:b0:5c9:5ac1:df6c with SMTP id 4fb4d7f45d1cf-5cea9732262mr4368916a12.33.1730417509658; Thu, 31 Oct 2024 16:31:49 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 31 Oct 2024 16:31:49 -0700 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:294641 Archived-At: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > I believe the time has come to change the default dialect. > I attached a suggested patch to do that. Sounds good to me. Legacy code can still run with a lexical-binding:nil cookie, so I think we're good in the backwards-compatibility department. Andrea and Eli? Some minor comments and questions on your patch below. > @@ -392,7 +392,7 @@ Void Variables > to evaluate the variable signals a @code{void-variable} error, instead > of returning a value. > > - Under the optional lexical scoping rule, the value cell only holds > + Under the optional lexical scoping rule, the value cell holds only > the variable's global value---the value outside of any lexical binding > construct. When a variable is lexically bound, the local value is > determined by the lexical environment; hence, variables can have local I think this section might need more work. It's a bit confusing to talk about "default dynamic scoping" and "optional lexical scoping" now. Shouldn't we talk about "normal variables with lexical scoping" and "special variables with dynamic scoping" or something along those lines? > diff --git a/lisp/loadup.el b/lisp/loadup.el > index bd74a9d6aff..e676c338c14 100644 > --- a/lisp/loadup.el > +++ b/lisp/loadup.el > @@ -654,9 +654,9 @@ comp-subr-arities-h > (unwind-protect > (let ((tmp-dump-mode dump-mode) > (dump-mode nil) > - ;; Set `lexical-binding' to nil by default > + ;; Set `lexical-binding' to its default value > ;; in the dumped Emacs. > - (lexical-binding nil)) > + (lexical-binding (default-toplevel-value 'lexical-binding))) > (if (member tmp-dump-mode '("pdump" "pbootstrap")) > (dump-emacs-portable (expand-file-name output invocation-directory)) > (dump-emacs output (if (eq system-type 'ms-dos) Why not just use `t` here instead of its `default-toplevel-value`? > diff --git a/src/lread.c b/src/lread.c > index ea0398196e3..9f56880e551 100644 > --- a/src/lread.c > +++ b/src/lread.c > @@ -1522,7 +1522,7 @@ DEFUN ("load", Fload, Sload, 1, 5, 0, > otherwise using a file-variable in the first line. This is bound here > so that it takes effect whether or not we use > Vload_source_file_function. */ > - specbind (Qlexical_binding, Qnil); > + specbind (Qlexical_binding, Fdefault_toplevel_value (Qlexical_binding)); > > Lisp_Object found_eff = > is_native_elisp And here? > @@ -2606,8 +2609,11 @@ DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 5, "", > specbind (Qstandard_output, tem); > record_unwind_protect_excursion (); > BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); > + lexical_cookie_t lexc = lisp_file_lexical_cookie (buf); > specbind (Qlexical_binding, > - lisp_file_lexical_cookie (buf) == Cookie_Lex ? Qt : Qnil); > + lexc == Cookie_Lex ? Qt > + : lexc == Cookie_Dyn ? Qnil > + : Fdefault_toplevel_value (Qlexical_binding)); > BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); > readevalloop (buf, 0, filename, > !NILP (printflag), unibyte, Qnil, Qnil, Qnil); And here?