emacs-devel
[Top][All Lists]
Advanced

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

Re: Default lexical-binding to t


From: Andrea Corallo
Subject: Re: Default lexical-binding to t
Date: Thu, 07 Nov 2024 18:00:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Richard Stallman <rms@gnu.org> writes:

> [[[ 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 believe by the time Emacs-31 will be released, such files will be
>   > > uncommon, and it is easy to fix them (either by adjusting he code, or
>   > > by slapping a `lexical-binding` cookie).
>
>   > I support this, together with the idea of having a warning when loading
>   > file without the cookie.  We can always remove the warning (and the
>   > cookies) in the future when/if we feel it's time.
>
> If the goal is to lead ysers to indicate this explicitly in each file,
> it is enough to complain about files that lack a file local variable
> specification for this variable.  It could do this whenever it visits
> a file in Emacs Lisp mode.

But a user could one day upgrade Emacs to a new emacs (with
lexical-binding t) and, without any feedback from Emacs, load an old file
with no cookie that was designed for dynamic bindings now interpreted as
lexical.  Most people load files without first fisiting them, so I still
think the load time warning idea has some advantage.

> If we want to increase the pressure to label old files explicitly,
> we could go beyond a warning.  For instance, we could ask the user
> whether. "Is this an old file thjt is supposed to use dynamic binding?"
>
> If the user answers yes to that, Emacs could offer to modify the file,
> adding a tag.

Yep that would be doable too.  I think increasing the pressure to label
old files explicitly is the goal here.

> By contrast, to change the interpretation of files that don't specify
> the variable is ineffective for the purpuse.  But it will waste a lot
> of long-time users' time in figuring out what went wrong.
>
> Eli wrote:
>
>   > If we urge people to specify lexical-binding in their files, then what
>   > is the point of making lexical-binding the default?
>
> Perhaps there is no reason to change the default itself ;-).  Perhaps
> what we _should_ want is to put an end, among somewhat-maintained
> programs, to dependence on the old defaull.
>
> The methods described above will do the job better and faster than
> changing the default, and much more gently too.

I believe having code with no cookie interpreted as lexical is anyway
the (final) goal on this subject.  Given all new code is lexically
scoped, one day would be nice not to have to keep on writing the cookie.
The cookie AFAIU was a workaraund put in place to have the coexistence
of the two dialects possible and allow for the transition, it is/was a
useful tool but would be nice in the future not to be forced to use it
everywhere.

Regards

  Andrea



reply via email to

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