[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Default lexical-binding to t
From: |
Alan Mackenzie |
Subject: |
Re: Default lexical-binding to t |
Date: |
Wed, 6 Nov 2024 22:50:57 +0000 |
Hello, Joost.
On Wed, Nov 06, 2024 at 21:48:05 +0100, Joost Kremers wrote:
> On Wed, Nov 06 2024, Alan Mackenzie wrote:
> > Maybe briefly explaining the philosophy of lexical binding somewhere
> > (maybe NEWS) would help.
> > I still don't understand it. I go along with lexical binding because
> > quite a lot of people cleverer than me have said it is good. But why?
> The Elisp manual has a few short remarks on it:
> (info "(elisp) Lexical Binding")
> ,----
> | Lexical binding was introduced to Emacs, as an optional feature, in
> | version 24.1. We expect its importance to increase with time. Lexical
> | binding opens up many more opportunities for optimization, so programs
> | using it are likely to run faster in future Emacs versions.
This was several major Emacs versions ago. Has anybody actually done
any measurements to demonstrate how effective this optimisation has
been? When I tried comparing dynamic vs. lexical .elc versions of CC
Mode scrolling through xdisp.c, dynamic took 8.3247s, lexical took
8.3285s. That's the same, within measurement accuracy.
> | Lexical
> | binding is also more compatible with concurrency, which was added to
> | Emacs in version 26.1.
> `----
I wonder what "more" compatible means. Concurrency doesn't appear to be
a major feature in Emacs, as far as I can tell.
> and:
> (info "(elisp) Dynamic Binding")
> ,----
> | Note that when code using Dynamic Binding is native compiled the
> | native compiler will not perform any Lisp specific optimization.
> `----
This looks like a choice not to support dynamic binding as well as
lexical binding. In my CC Mode benchmark (see above) with native
compiled code, the lexical binding version was somewhat faster than the
dynamic binding one, around 10%. But the native compiled code was
scarcely faster than the byte compiled code.
> AFAIU, dynamic binding is especially dangerous if you're in the habit of
> setting variables without let-binding them. A coding style that was perhaps
> more common in the past than it is now.
I think you get a warning from the byte compiler for this, and have done
for many Emacs versions.
With lexical binding, I get the impression of an unstoppable juggernaut,
something with momentum of its own, careering ahead without anybody
being able to stop it or even question it. I doubt it will do Emacs any
harm, once all the old .el files have been equipped with a -*- lexical
binding: nil -*- comment. But I do wonder whether the massive time and
effort its development and proliferation have taken up were worth it.
> --
> Joost Kremers
> Life has its moments
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Default lexical-binding to t, (continued)
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/04
- Re: Default lexical-binding to t, Stefan Monnier, 2024/11/05
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/06
- Re: Default lexical-binding to t, Stefan Monnier, 2024/11/06
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/06
- Re: Default lexical-binding to t, Stefan Monnier, 2024/11/06
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/06
- Re: Default lexical-binding to t, Alan Mackenzie, 2024/11/06
- Re: Default lexical-binding to t, Joost Kremers, 2024/11/06
- Re: Default lexical-binding to t,
Alan Mackenzie <=
- Re: Default lexical-binding to t, Stefan Kangas, 2024/11/06
- Re: Default lexical-binding to t, Alan Mackenzie, 2024/11/07
- Re: Default lexical-binding to t, Stefan Kangas, 2024/11/07
- Re: Default lexical-binding to t, Richard Stallman, 2024/11/09
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/07
- Re: Default lexical-binding to t, Joost Kremers, 2024/11/07
- Re: Default lexical-binding to t, Eli Zaretskii, 2024/11/07
- Re: Default lexical-binding to t, tomas, 2024/11/07
- Re: Default lexical-binding to t, Alan Mackenzie, 2024/11/07
- Re: Default lexical-binding to t, Dmitry Gutov, 2024/11/07