all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Declaring 'lexical-binding: nil' obsolete
@ 2021-09-25 22:47 Stefan Kangas
  2021-09-25 23:17 ` Po Lu
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Stefan Kangas @ 2021-09-25 22:47 UTC (permalink / raw)
  To: Emacs developers; +Cc: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 2197 bytes --]

Hi all,

Lexical binding has been with us since Emacs 24.1, released on
2012-06-10, almost ten years ago.  In Emacs 28.1, we will have no files
that do not use lexical-binding.[1]

I think it is time to formally declare the "lexical-binding:nil" dialect
of Emacs Lisp obsolete.

I have been thinking about what a roadmap could look like, and I would
like to propose a roadmap, best explained by this NEWS entry:

    ** 'lexical-binding: nil' is now obsolete.
    The old 'lexical-binding:nil' dialect of Emacs Lisp is now obsolete.
    Third-party code will need to be changed to support
    'lexical-binding:t' to run properly on Emacs in the future.

    We expect that this transition will be very smooth in most cases.
    See the Info node "(elisp) Converting to Lexical Binding" in
    the Emacs Lisp reference manual for some advice.

    For now, the most visible effect of this is that there is a warning
    when byte-compiling a file that does not specify lexical-binding to
    either nil or t.  This is intended as a stop-gap, and we will
    eventually warn if this variable is nil.

    The plan for phasing out 'lexical-binding:nil' is as follows:

    Emacs 28.1 - The byte-compiler warns if there is no 'lexical-binding'
                 cookie.

    Emacs 30.1 - The byte-compiler warns if there is no 'lexical-binding'
                 cookie, or if the cookie is 'lexical-binding:nil'.

    Emacs 32.1 - The warnings remain as before, and 'lexical-binding:t' is
                 the default.

The version numbers in this plan could be adjusted, but the ones I
propose should already give us most of the next decade before we
actually flip the switch.  In any case, whatever we decide now could
easily be adjusted in the future if needed.

Please see the attached patch for an idea of what this obsoletion might
amount to in terms of code.  It basically adds the following
byte-compiler warning:

    In toplevel form:
    lisp/foobar.el: Warning: First line should contain either
        "-*-lexical-binding:t-*-" or "-*-lexical-binding:nil-*-".

Footnotes:
[1] org-agenda.el still has no cookie, but it will once the latest
     version of Org-mode is merged into our tree.

[-- Attachment #2: 0001-Make-lexical-binding-nil-obsolete.patch --]
[-- Type: text/x-diff, Size: 4418 bytes --]

From f86c70ee0c7e69536c1741c30376e54dac7f8526 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sat, 25 Sep 2021 23:08:53 +0200
Subject: [PATCH] Make 'lexical-binding: nil' obsolete

* etc/NEWS: Announce obsoletion of 'lexical-binding: nil'.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Warn if there
is no 'lexical-binding' statement on the first line.
* lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Change tooltip to
say that "dynamic scoping mode" is obsolete.  Use error face.
Warn when opening a file that does not use 'lexical-binding:t'.
---
 etc/NEWS                     | 25 +++++++++++++++++++++++++
 lisp/emacs-lisp/bytecomp.el  |  4 ++++
 lisp/progmodes/elisp-mode.el | 12 +++++++++---
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index d77d34160b..11d04c4d2a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3150,6 +3150,31 @@ This new 'etc-authors-mode' provides font-locking for displaying the
 \f
 * Incompatible Editing Changes in Emacs 28.1
 
+** 'lexical-binding: nil' is now obsolete.
+The old 'lexical-binding:nil' dialect of Emacs Lisp is now obsolete.
+Third-party code will need to be changed to support
+'lexical-binding:t' to run properly on Emacs in the future.
+
+We expect that this transition will be very smooth in most cases.
+See the Info node "(elisp) Converting to Lexical Binding" in
+the Emacs Lisp reference manual for some advice.
+
+For now, the most visible effect of this is that there is a warning
+when byte-compiling a file that does not specify lexical-binding to
+either nil or t.  This is intended as a stop-gap, and we will
+eventually warn if this variable is nil.
+
+The plan for phasing out 'lexical-binding:nil' is as follows:
+
+Emacs 28.1 - The byte-compiler warns if there is no 'lexical-binding'
+             cookie.
+
+Emacs 30.1 - The byte-compiler warns if there is no 'lexical-binding'
+             cookie, or if the cookie is 'lexical-binding:nil'.
+
+Emacs 32.1 - The warnings remain as before, and 'lexical-binding:t' is
+             the default.
+
 ---
 ** 'toggle-truncate-lines' now disables 'visual-line-mode'.
 This is for symmetry with 'visual-line-mode', which disables
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d7da7a2149..3f220a4991 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2050,7 +2050,11 @@ byte-compile-file
         (setq buffer-read-only nil
               filename buffer-file-name))
       ;; Don't inherit lexical-binding from caller (bug#12938).
+      ;; Warn if there is no 'lexical-binding' cookie.
       (unless (local-variable-p 'lexical-binding)
+        (byte-compile-warn "\
+First line should contain either \"-*-lexical-binding:t-*-\" \
+or \"-*-lexical-binding:nil-*-\".")
         (setq-local lexical-binding nil))
       ;; Set the default directory, in case an eval-when-compile uses it.
       (setq default-directory (file-name-directory filename)))
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 0b2395d976..096c4e18cb 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -281,9 +281,9 @@ emacs-lisp-mode
     (lexical-binding (:propertize "/l"
                       help-echo "Using lexical-binding mode")
                      (:propertize "/d"
-                      help-echo "Using old dynamic scoping mode\n\
+                      help-echo "Using obsolete dynamic scoping mode\n\
 mouse-1: Enable lexical-binding mode"
-		      face warning
+                      face error
 		      mouse-face mode-line-highlight
                       local-map ,elisp--dynlex-modeline-map)))
   "Major mode for editing Lisp code to run in Emacs.
@@ -319,7 +319,13 @@ emacs-lisp-mode
   (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
   (add-hook 'flymake-diagnostic-functions
               #'elisp-flymake-byte-compile nil t)
-  (add-hook 'context-menu-functions #'elisp-context-menu 10 t))
+  (add-hook 'context-menu-functions #'elisp-context-menu 10 t)
+  (when (and (not lexical-binding) buffer-file-name)
+    (message (format-message
+              (concat "Warning: `%s' is using the obsolete "
+                      "`lexical-binding:nil' version of "
+                      "Emacs Lisp")
+              (file-name-nondirectory buffer-file-name)))))
 
 ;; Font-locking support.
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-25 22:47 Declaring 'lexical-binding: nil' obsolete Stefan Kangas
@ 2021-09-25 23:17 ` Po Lu
  2021-09-26  0:04   ` Stefan Kangas
  2021-09-25 23:56 ` Eduardo Ochs
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Po Lu @ 2021-09-25 23:17 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Emacs developers, Stefan Monnier

Stefan Kangas <stefan@marxist.se> writes:

> Lexical binding has been with us since Emacs 24.1, released on
> 2012-06-10, almost ten years ago.  In Emacs 28.1, we will have no files
> that do not use lexical-binding.[1]
>
> I think it is time to formally declare the "lexical-binding:nil" dialect
> of Emacs Lisp obsolete.

But countless amounts of user code might be made obsolete by this
change, including a great deal of my own.  And I (and presumably other
people) will have no time to adjust to this change.

Even if it is obsoleted at some point, it is IMO very premature to do
right now.

Thanks.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-25 22:47 Declaring 'lexical-binding: nil' obsolete Stefan Kangas
  2021-09-25 23:17 ` Po Lu
@ 2021-09-25 23:56 ` Eduardo Ochs
  2021-09-26  0:35   ` Stefan Kangas
  2021-09-26  6:02 ` Eli Zaretskii
  2021-09-27 22:35 ` Deprecating 'lexical-binding: nil' Richard Stallman
  3 siblings, 1 reply; 20+ messages in thread
From: Eduardo Ochs @ 2021-09-25 23:56 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Stefan Monnier, Emacs developers

Let me double-check... so is it enough to add a

  -*- lexical-binding: nil; -*-

to the end of the first line of each of our ".el" files?

All the files of eev use dynamic binding... and they are also marked
with "no-byte-compile: t" for reasons explained here,

  http://angg.twu.net/eev-intros/find-eev-install-intro.html#7.1
  (find-eev-install-intro "7.1. Byte-compilation")

So I don't usually see the byte-compiler warnings...

  [[]],
    Eduardo Ochs
    http://angg.twu.net/#eev

On Sat, 25 Sept 2021 at 19:49, Stefan Kangas <stefan@marxist.se> wrote:
>
> Hi all,
>
> Lexical binding has been with us since Emacs 24.1, released on
> 2012-06-10, almost ten years ago.  In Emacs 28.1, we will have no files
> that do not use lexical-binding.[1]
>
> I think it is time to formally declare the "lexical-binding:nil" dialect
> of Emacs Lisp obsolete.
>
> I have been thinking about what a roadmap could look like, and I would
> like to propose a roadmap, best explained by this NEWS entry:
>
>     ** 'lexical-binding: nil' is now obsolete.
>     The old 'lexical-binding:nil' dialect of Emacs Lisp is now obsolete.
>     Third-party code will need to be changed to support
>     'lexical-binding:t' to run properly on Emacs in the future.
>
>     We expect that this transition will be very smooth in most cases.
>     See the Info node "(elisp) Converting to Lexical Binding" in
>     the Emacs Lisp reference manual for some advice.
>
>     For now, the most visible effect of this is that there is a warning
>     when byte-compiling a file that does not specify lexical-binding to
>     either nil or t.  This is intended as a stop-gap, and we will
>     eventually warn if this variable is nil.
>
>     The plan for phasing out 'lexical-binding:nil' is as follows:
>
>     Emacs 28.1 - The byte-compiler warns if there is no 'lexical-binding'
>                  cookie.
>
>     Emacs 30.1 - The byte-compiler warns if there is no 'lexical-binding'
>                  cookie, or if the cookie is 'lexical-binding:nil'.
>
>     Emacs 32.1 - The warnings remain as before, and 'lexical-binding:t' is
>                  the default.
>
> The version numbers in this plan could be adjusted, but the ones I
> propose should already give us most of the next decade before we
> actually flip the switch.  In any case, whatever we decide now could
> easily be adjusted in the future if needed.
>
> Please see the attached patch for an idea of what this obsoletion might
> amount to in terms of code.  It basically adds the following
> byte-compiler warning:
>
>     In toplevel form:
>     lisp/foobar.el: Warning: First line should contain either
>         "-*-lexical-binding:t-*-" or "-*-lexical-binding:nil-*-".
>
> Footnotes:
> [1] org-agenda.el still has no cookie, but it will once the latest
>      version of Org-mode is merged into our tree.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-25 23:17 ` Po Lu
@ 2021-09-26  0:04   ` Stefan Kangas
  2021-09-26  0:13     ` Po Lu
  2021-09-26  6:06     ` Eli Zaretskii
  0 siblings, 2 replies; 20+ messages in thread
From: Stefan Kangas @ 2021-09-26  0:04 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Monnier, Emacs developers

Po Lu <luangruo@yahoo.com> writes:

> But countless amounts of user code might be made obsolete by this
> change, including a great deal of my own.  And I (and presumably other
> people) will have no time to adjust to this change.

The roadmap I propose will give you a decade or so to adjust, and even
then will you only need to change one line per ELisp file for it to work
just as it does today.

Before then, the worst that will happen is that you will see a warning.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:04   ` Stefan Kangas
@ 2021-09-26  0:13     ` Po Lu
  2021-09-26  0:50       ` Stefan Kangas
  2021-09-26  6:08       ` Eli Zaretskii
  2021-09-26  6:06     ` Eli Zaretskii
  1 sibling, 2 replies; 20+ messages in thread
From: Po Lu @ 2021-09-26  0:13 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Stefan Monnier, Emacs developers

Stefan Kangas <stefan@marxist.se> writes:

> The roadmap I propose will give you a decade or so to adjust, and even
> then will you only need to change one line per ELisp file for it to work
> just as it does today.
>
> Before then, the worst that will happen is that you will see a warning.

Yes, but is there any compelling reason other than "it's obsolete" to
make this change?

If it's to prevent new Emacs Lisp authors from inadvertently writing
dynamically-bound code, I suggest to rewrite (eintr)Prevent confusion
and other places in the documentation aimed at new users that seem to
encourage them to write dynamically-bound code.  I'm sure that a large
part of the dynamically bound code present today stems from users not
knowing better; instead of a blanket obsoletion, better and more
immediate solutions can be found, such as updating the Introduction to
Programming in Emacs Lisp to not refer users to dynamic binding.

Perhaps a notice in Emacs Lisp mode when creating new dynamically bound
files would also be prudent. (For instance: "This file is being
dynamically bound.  If you don't intend for it to be this way, please
read (elisp)Lexical Binding")



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-25 23:56 ` Eduardo Ochs
@ 2021-09-26  0:35   ` Stefan Kangas
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Kangas @ 2021-09-26  0:35 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: Stefan Monnier, Emacs developers

Eduardo Ochs <eduardoochs@gmail.com> writes:

> Let me double-check... so is it enough to add a
>
>   -*- lexical-binding: nil; -*-
>
> to the end of the first line of each of our ".el" files?

According to this proposal, yes.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:13     ` Po Lu
@ 2021-09-26  0:50       ` Stefan Kangas
  2021-09-26  1:20         ` Po Lu
  2021-09-26  6:30         ` Eli Zaretskii
  2021-09-26  6:08       ` Eli Zaretskii
  1 sibling, 2 replies; 20+ messages in thread
From: Stefan Kangas @ 2021-09-26  0:50 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Monnier, Emacs developers

Po Lu <luangruo@yahoo.com> writes:

> Stefan Kangas <stefan@marxist.se> writes:
>
>> The roadmap I propose will give you a decade or so to adjust, and even
>> then will you only need to change one line per ELisp file for it to work
>> just as it does today.
>>
>> Before then, the worst that will happen is that you will see a warning.
>
> Yes, but is there any compelling reason other than "it's obsolete" to
> make this change?

Is there any compelling reason not to?

Of course we have plenty of compelling reasons, but the main one is that
we currently have two dialects of Emacs Lisp, where it would be better
and less confusing to have one.

> If it's to prevent new Emacs Lisp authors from inadvertently writing
> dynamically-bound code, I suggest to rewrite (eintr)Prevent confusion
> and other places in the documentation aimed at new users that seem to
> encourage them to write dynamically-bound code.  I'm sure that a large
> part of the dynamically bound code present today stems from users not
> knowing better; instead of a blanket obsoletion, better and more
> immediate solutions can be found, such as updating the Introduction to
> Programming in Emacs Lisp to not refer users to dynamic binding.

I'm sure that we will review those parts of the documentation in due
time.  But the "blanket" (not sure why you add this word) obsoletion is
precisely about discouraging the use of the 'lexical-binding:nil'
dialect of Emacs Lisp.

If you read my proposal carefully, I hope it is clear that this
obsoletion mostly just entails our strong recommendation.  Support for
'lexical-binding:nil' will need to be there for the foreseeable future.
I do not include removing this feature in the plan I propose, and this
is not by accident.

> Perhaps a notice in Emacs Lisp mode when creating new dynamically bound
> files would also be prudent. (For instance: "This file is being
> dynamically bound.  If you don't intend for it to be this way, please
> read (elisp)Lexical Binding")

(Note that we already have a warning in the mode-line.)



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:50       ` Stefan Kangas
@ 2021-09-26  1:20         ` Po Lu
  2021-09-26  2:37           ` Stefan Kangas
  2021-09-26  6:30         ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Po Lu @ 2021-09-26  1:20 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Stefan Monnier, Emacs developers

Stefan Kangas <stefan@marxist.se> writes:

> I'm sure that we will review those parts of the documentation in due
> time.  But the "blanket" (not sure why you add this word) obsoletion is
> precisely about discouraging the use of the 'lexical-binding:nil'
> dialect of Emacs Lisp.

Obsoletion is not discouragement!  Making something obsolete puts it on
the path to removal.

> If you read my proposal carefully, I hope it is clear that this
> obsoletion mostly just entails our strong recommendation.  Support for
> 'lexical-binding:nil' will need to be there for the foreseeable future.

Yes, but why would it need to be the subject of a byte-compiler warning?
Adding a warning to the byte compiler will only cause more confusion,
because the documentation doesn't suggest lexical binding in particular.

New authors of third-party code who have learned Emacs Lisp from the
Eintr will be even more confused, because the byte-compiler is directly
behaving in a way inconsistent with the documentation they learned from.

Meanwhile, if the byte compiler is left alone while the documentation is
updated to reflect the new recommendations, the situation will not be as
confusing.

> I do not include removing this feature in the plan I propose, and this
> is not by accident.

But why does the NEWS entry you have proposed include:

    Third-party code will need to be changed to support
    'lexical-binding:t' to run properly on Emacs in the future.

> (Note that we already have a warning in the mode-line.)

Perhaps it should be made more noticable, at least the first time it is
shown?  The way it is now, most people will consider it a warning, only
an indicator.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  1:20         ` Po Lu
@ 2021-09-26  2:37           ` Stefan Kangas
  2021-09-26  2:55             ` Po Lu
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Kangas @ 2021-09-26  2:37 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Monnier, Emacs developers

Po Lu <luangruo@yahoo.com> writes:

> Obsoletion is not discouragement!  Making something obsolete puts it on
> the path to removal.

That's the general idea, but it doesn't bind us to any particular
timetable, certainly not one where users won't have time to adapt.

> Yes, but why would it need to be the subject of a byte-compiler warning?
> Adding a warning to the byte compiler will only cause more confusion,
> because the documentation doesn't suggest lexical binding in particular.

I disagree; the warning is clear.

Where the documentation is not yet updated to recommend lexical binding,
it should be fixed.

> But why does the NEWS entry you have proposed include:
>
>     Third-party code will need to be changed to support
>     'lexical-binding:t' to run properly on Emacs in the future.

Because this is true if the plan is to change the default.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  2:37           ` Stefan Kangas
@ 2021-09-26  2:55             ` Po Lu
  0 siblings, 0 replies; 20+ messages in thread
From: Po Lu @ 2021-09-26  2:55 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Stefan Monnier, Emacs developers

Stefan Kangas <stefan@marxist.se> writes:

> I disagree; the warning is clear.

The problem is not something that a byte compiler warning will solve.
Updating the documentation will do much more to solve that, than a
byte-compiler warning.

> Where the documentation is not yet updated to recommend lexical binding,
> it should be fixed.

Yes, agreed.

>> But why does the NEWS entry you have proposed include:
>>
>>     Third-party code will need to be changed to support
>>     'lexical-binding:t' to run properly on Emacs in the future.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Because this is true if the plan is to change the default.

So in the future, dynamically bound code (lexical-binding: nil) must
also work with lexical binding (lexical-binding: t)?

That amounts to a removal of the dynamically bound variant of Emacs
Lisp.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-25 22:47 Declaring 'lexical-binding: nil' obsolete Stefan Kangas
  2021-09-25 23:17 ` Po Lu
  2021-09-25 23:56 ` Eduardo Ochs
@ 2021-09-26  6:02 ` Eli Zaretskii
  2021-09-26  6:36   ` Lars Ingebrigtsen
  2021-09-27 22:35 ` Deprecating 'lexical-binding: nil' Richard Stallman
  3 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2021-09-26  6:02 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: monnier, emacs-devel

> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 25 Sep 2021 15:47:45 -0700
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>
> 
> Lexical binding has been with us since Emacs 24.1, released on
> 2012-06-10, almost ten years ago.  In Emacs 28.1, we will have no files
> that do not use lexical-binding.[1]
> 
> I think it is time to formally declare the "lexical-binding:nil" dialect
> of Emacs Lisp obsolete.

Not in Emacs 28, please.  We need to collect experience "in the wild"
before we decide on the next steps, and for now the 100% coverage was
limited to those who track the master branch.  That is not enough,
IMO.  It definitely doesn't justify starting to warn users in Emacs
28.1.

Moreover, in general I see no need to rush this stuff.  There's no
urgency whatsoever.  Dynamic binding is not harmful.  We have much
more important issues on our plate to push forward, let's focus our
efforts on them instead.

>     The plan for phasing out 'lexical-binding:nil' is as follows:
> 
>     Emacs 28.1 - The byte-compiler warns if there is no 'lexical-binding'
>                  cookie.
> 
>     Emacs 30.1 - The byte-compiler warns if there is no 'lexical-binding'
>                  cookie, or if the cookie is 'lexical-binding:nil'.
> 
>     Emacs 32.1 - The warnings remain as before, and 'lexical-binding:t' is
>                  the default.

Please shift the major version numbers by 1 (at the very least).



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:04   ` Stefan Kangas
  2021-09-26  0:13     ` Po Lu
@ 2021-09-26  6:06     ` Eli Zaretskii
  1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2021-09-26  6:06 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: luangruo, monnier, emacs-devel

> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 25 Sep 2021 17:04:46 -0700
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  Emacs developers <emacs-devel@gnu.org>
> 
> Po Lu <luangruo@yahoo.com> writes:
> 
> > But countless amounts of user code might be made obsolete by this
> > change, including a great deal of my own.  And I (and presumably other
> > people) will have no time to adjust to this change.
> 
> The roadmap I propose will give you a decade or so to adjust, and even
> then will you only need to change one line per ELisp file for it to work
> just as it does today.
> 
> Before then, the worst that will happen is that you will see a warning.

Unwarranted warnings are baaad...  Especially when there's nothing
wrong with the code, really.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:13     ` Po Lu
  2021-09-26  0:50       ` Stefan Kangas
@ 2021-09-26  6:08       ` Eli Zaretskii
  1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2021-09-26  6:08 UTC (permalink / raw)
  To: Po Lu; +Cc: stefan, monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  Emacs developers
>  <emacs-devel@gnu.org>
> Date: Sun, 26 Sep 2021 08:13:49 +0800
> 
> If it's to prevent new Emacs Lisp authors from inadvertently writing
> dynamically-bound code, I suggest to rewrite (eintr)Prevent confusion
> and other places in the documentation aimed at new users that seem to
> encourage them to write dynamically-bound code.

There's no need: we already show with prominent color in the mode line
the fact that the code uses dynamic bindings.  So people already have
the indication which is pretty much in their face, which is much more
efficient than any writeup in the manual.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  0:50       ` Stefan Kangas
  2021-09-26  1:20         ` Po Lu
@ 2021-09-26  6:30         ` Eli Zaretskii
  1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2021-09-26  6:30 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: luangruo, monnier, emacs-devel

> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 25 Sep 2021 17:50:52 -0700
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  Emacs developers <emacs-devel@gnu.org>
> 
> Of course we have plenty of compelling reasons, but the main one is that
> we currently have two dialects of Emacs Lisp, where it would be better
> and less confusing to have one.

Actually, we have more than 2: we also have the cl-lib/cl-macs
dialect, and then we have the cl-defgeneric dialect, the pcase
dialect, and probably a few more.  They all look like different
programming languages to me, but that doesn't seem to bother anyone,
and we aren't going to evict any of them in favor of others any time
soon, are we?

> If you read my proposal carefully, I hope it is clear that this
> obsoletion mostly just entails our strong recommendation.

Recommendations should be documented as such (and we have quite a few
of them in our manuals), and perhaps flagged by checkdoc and other
similar linting tools, but warning about them is IMO inappropriate.

> (Note that we already have a warning in the mode-line.)

Yes, and why isn't that enough?



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Declaring 'lexical-binding: nil' obsolete
  2021-09-26  6:02 ` Eli Zaretskii
@ 2021-09-26  6:36   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 20+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-26  6:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Kangas, monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Not in Emacs 28, please.  We need to collect experience "in the wild"
> before we decide on the next steps, and for now the 100% coverage was
> limited to those who track the master branch.  That is not enough,
> IMO.  It definitely doesn't justify starting to warn users in Emacs
> 28.1.

I agree.  We've just this week gotten the final file converted in Emacs
itself, so it seems too soon to start bugging external packages about
this.

I think it'd be fine in Emacs 29, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Deprecating 'lexical-binding: nil'
  2021-09-25 22:47 Declaring 'lexical-binding: nil' obsolete Stefan Kangas
                   ` (2 preceding siblings ...)
  2021-09-26  6:02 ` Eli Zaretskii
@ 2021-09-27 22:35 ` Richard Stallman
  2021-09-27 23:09   ` Stefan Kangas
  3 siblings, 1 reply; 20+ messages in thread
From: Richard Stallman @ 2021-09-27 22:35 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: monnier, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I support making lexical binding the default, eventually, but instead
of proposing to make nonlexical binding mode obsolete (which implies
removing it), let's stop with deprecating it.

To delete a mode of usage that was formerly the default would make it
almost unfrasible to run old Lisp programs in newer Emacs versions.

The changes required to make those old programs function with lexical
binding are not simple or eash to write.  You can't find them by
searching for certain names, as you could for many other incompatible
changes.  In some cases, they require studying the code carefully.

To avoid that, let's keep the nonlexical mode working.

I like Stefan's proposal for the approach for doing that:

      > The plan for phasing out 'lexical-binding:nil' is as follows:

      > Emacs 28.1 - The byte-compiler warns if there is no 'lexical-binding'
      >              cookie.

      > Emacs 30.1 - The byte-compiler warns if there is no 'lexical-binding'
      >              cookie, or if the cookie is 'lexical-binding:nil'.

      > Emacs 32.1 - The warnings remain as before, and 'lexical-binding:t' is
      >              the default.

One good thing is that this plans for it to take many years.  It took
us 10 years to switch in Emacs, and we are to some extent organized.
The user community is not organized and will not be quick to switch.

Another is that there will be two stages of warnings, proposed here
for Emacs 28 and Emacs 30.  Each warning will convince some users to
switch, so two warning stages are better than one.

I have no opinion about whether to take the first step in Emacs 28 or
in Emacs 29.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Deprecating 'lexical-binding: nil'
  2021-09-27 22:35 ` Deprecating 'lexical-binding: nil' Richard Stallman
@ 2021-09-27 23:09   ` Stefan Kangas
  2021-09-28  1:42     ` Stefan Monnier
  2021-09-30  6:03     ` Richard Stallman
  0 siblings, 2 replies; 20+ messages in thread
From: Stefan Kangas @ 2021-09-27 23:09 UTC (permalink / raw)
  To: rms; +Cc: monnier, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> I support making lexical binding the default, eventually, but instead
> of proposing to make nonlexical binding mode obsolete (which implies
> removing it), let's stop with deprecating it.

That is fine by me, thank you.

Note that I was a bit careless in my choice of words here: the subject
said "deprecated" but the actual text said "obsolete".  I think
"deprecated" better communicates the intention here.

> To delete a mode of usage that was formerly the default would make it
> almost unfrasible to run old Lisp programs in newer Emacs versions.
>
> The changes required to make those old programs function with lexical
> binding are not simple or eash to write.  You can't find them by
> searching for certain names, as you could for many other incompatible
> changes.  In some cases, they require studying the code carefully.
>
> To avoid that, let's keep the nonlexical mode working.

I agree.  For the record, it was never my intention to suggest that we
should rush to delete 'lexical-binding:nil'.  My expectation is that it
will be phased out at some point in the future when it is no longer
really relevant.

Or maybe the future maintainers of Emacs will decide that it makes sense
to keep it around as a novelty.  You know, much like how most Unix-like
operating systems still come with vi.  ;-)

> I have no opinion about whether to take the first step in Emacs 28 or
> in Emacs 29.

Both our maintainers have said that they don't want this in Emacs 28,
and I can understand their reasoning.

We can revisit this after 28.1 has been released, and some time have
passed.  My hope is that we will be able to finally declare it
deprecated in Emacs 29.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Deprecating 'lexical-binding: nil'
  2021-09-27 23:09   ` Stefan Kangas
@ 2021-09-28  1:42     ` Stefan Monnier
  2021-09-30  6:03     ` Richard Stallman
  1 sibling, 0 replies; 20+ messages in thread
From: Stefan Monnier @ 2021-09-28  1:42 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: rms, emacs-devel

> We can revisit this after 28.1 has been released, and some time have
> passed.  My hope is that we will be able to finally declare it
> deprecated in Emacs 29.

We could also install the new warning in `master` soon after the
`emacs-28` branch is cut (i.e. it will only be released into Emacs-29.1
but people who follow `master` will be exposed to it sooner).


        Stefan




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Deprecating 'lexical-binding: nil'
  2021-09-27 23:09   ` Stefan Kangas
  2021-09-28  1:42     ` Stefan Monnier
@ 2021-09-30  6:03     ` Richard Stallman
  2021-09-30 14:18       ` Steingold
  1 sibling, 1 reply; 20+ messages in thread
From: Richard Stallman @ 2021-09-30  6:03 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: monnier, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I agree.  For the record, it was never my intention to suggest that we
  > should rush to delete 'lexical-binding:nil'.  My expectation is that it
  > will be phased out at some point in the future when it is no longer
  > really relevant.

We should never remove nonlexical mode.  To remove it would break old
Emacs Lisp programs in a way that is very hard to fix.  With most of
our incompatible changes, it is easy to find the things that need to
be fixed.  So it is not such a big obstacle to running old programs.
This would make old programs useless.

Mere simplification can't justify that.

This is not a mere "novelty".

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Deprecating 'lexical-binding: nil'
  2021-09-30  6:03     ` Richard Stallman
@ 2021-09-30 14:18       ` Steingold
  0 siblings, 0 replies; 20+ messages in thread
From: Steingold @ 2021-09-30 14:18 UTC (permalink / raw)
  To: emacs-devel

> * Richard Stallman <ezf@tah.bet> [2021-09-30 02:03:12 -0400]:
>
> We should never remove nonlexical mode.  To remove it would break old
> Emacs Lisp programs in a way that is very hard to fix.  ...
> This would make old programs useless.

Not really.
I wrote elisp.lisp (http://clocc.hg.sourceforge.net/hgweb/clocc/clocc/raw-file/tip/src/cllib/elisp.lisp)
years ago to run ELisp code (that uses dynamic bindings)
under Common Lisp (that uses lexical bindings).
(The gist is to explicitly `declare` all variables `special`).
So, at the very least those old emacs lisp programs will still be
usable under CL.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1894
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://jihadwatch.org https://iris.org.il https://memri.org
nobody's life, liberty or property are safe while the legislature is in session




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-09-30 14:18 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-25 22:47 Declaring 'lexical-binding: nil' obsolete Stefan Kangas
2021-09-25 23:17 ` Po Lu
2021-09-26  0:04   ` Stefan Kangas
2021-09-26  0:13     ` Po Lu
2021-09-26  0:50       ` Stefan Kangas
2021-09-26  1:20         ` Po Lu
2021-09-26  2:37           ` Stefan Kangas
2021-09-26  2:55             ` Po Lu
2021-09-26  6:30         ` Eli Zaretskii
2021-09-26  6:08       ` Eli Zaretskii
2021-09-26  6:06     ` Eli Zaretskii
2021-09-25 23:56 ` Eduardo Ochs
2021-09-26  0:35   ` Stefan Kangas
2021-09-26  6:02 ` Eli Zaretskii
2021-09-26  6:36   ` Lars Ingebrigtsen
2021-09-27 22:35 ` Deprecating 'lexical-binding: nil' Richard Stallman
2021-09-27 23:09   ` Stefan Kangas
2021-09-28  1:42     ` Stefan Monnier
2021-09-30  6:03     ` Richard Stallman
2021-09-30 14:18       ` Steingold

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.