From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Default lexical-binding to t Date: Wed, 6 Nov 2024 22:50:57 +0000 Message-ID: References: <86ttcnuppm.fsf@gnu.org> <86ttcksgsu.fsf@gnu.org> <86bjysscvr.fsf@gnu.org> <86v7x0w0l6.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7705"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Joost Kremers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 06 23:51:45 2024 Return-path: Envelope-to: ged-emacs-devel@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 1t8osL-0001tu-88 for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Nov 2024 23:51:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8org-00061O-Lw; Wed, 06 Nov 2024 17:51:04 -0500 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 1t8orf-000610-6X for emacs-devel@gnu.org; Wed, 06 Nov 2024 17:51:03 -0500 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8ord-0000AW-5e for emacs-devel@gnu.org; Wed, 06 Nov 2024 17:51:02 -0500 Original-Received: (qmail 21825 invoked by uid 3782); 6 Nov 2024 23:50:58 +0100 Original-Received: from muc.de (p4fe15b0f.dip0.t-ipconnect.de [79.225.91.15]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 06 Nov 2024 23:50:57 +0100 Original-Received: (qmail 17305 invoked by uid 1000); 6 Nov 2024 22:50:57 -0000 Content-Disposition: inline In-Reply-To: <86v7x0w0l6.fsf@fastmail.fm> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325191 Archived-At: 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).