emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Declaring 'lexical-binding: nil' obsolete


From: Stefan Kangas
Subject: Declaring 'lexical-binding: nil' obsolete
Date: Sat, 25 Sep 2021 15:47:45 -0700

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: 0001-Make-lexical-binding-nil-obsolete.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]