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.cc-mode.general,gmane.emacs.devel Subject: Re: lexical-binding in CC-mode Date: Tue, 6 Apr 2021 16:19:08 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21407"; mail-complaints-to="usenet@ciao.gmane.io" Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Tue Apr 06 18:19:40 2021 Return-path: Envelope-to: sf-cc-mode-help@m.gmane-mx.org Original-Received: from lists.sourceforge.net ([216.105.38.7]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lToQW-0005Si-65 for sf-cc-mode-help@m.gmane-mx.org; Tue, 06 Apr 2021 18:19:40 +0200 Original-Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lToQQ-0007v0-Es; Tue, 06 Apr 2021 16:19:34 +0000 Original-Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lToQP-0007um-CQ for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 16:19:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=From:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+F3r4Nv/oVE7/2V08/LypsIkkPKPxGuP/95MokS5aD4=; b=S4C1EZl4M+C00u0wgpYEIDaZY zIFe6VCrfUUuiGQRYMLrfvoJtmIJrlZtnImNxrVvZmva/ZTzsvhFM3kmI35ejDszg9Nlq05dtpbtm N0A9Mhak0qTMcMOAV1LUpNv64qLHvS7fwmE7USoCz1SAFZQY17rHatAnBSWVAo3662HxE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject: Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+F3r4Nv/oVE7/2V08/LypsIkkPKPxGuP/95MokS5aD4=; b=aM/iFPI+IfNvbdb+RaVSFZ/27o s7jU01mbUE6bJM2X3/3tHYzMYKrfmjlugU8fLGHI2DF22R3nPvUisgSbgTYaqGmMhUkZ/vA2tuGBL 4+sQGc/bj1CTnnN1AvRztWeNHVLF48nckbuDA+8WzoqW5lxrsdqE9NEP5KSD8WtxhXoA=; Original-Received: from eggs.gnu.org ([209.51.188.92]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1lToQF-00BaTJ-4C for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 16:19:33 +0000 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53617) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lToQ8-0008Dh-7g for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 12:19:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39206) by fencepost.gnu.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lToQ7-0007EL-S6 for bug-cc-mode@gnu.org; Tue, 06 Apr 2021 12:19:16 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:26759 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1lToQ5-0008Aw-Sx for bug-cc-mode@gnu.org; Tue, 06 Apr 2021 12:19:15 -0400 Original-Received: (qmail 78904 invoked by uid 3782); 6 Apr 2021 16:19:09 -0000 Original-Received: from acm.muc.de (p4fe15a5c.dip0.t-ipconnect.de [79.225.90.92]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 06 Apr 2021 18:19:08 +0200 Original-Received: (qmail 7590 invoked by uid 1000); 6 Apr 2021 16:19:08 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Headers-End: 1lToQF-00BaTJ-4C X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.io gmane.emacs.cc-mode.general:8202 gmane.emacs.devel:267482 Archived-At: Hello, Stefan. On Mon, Apr 05, 2021 at 14:38:08 -0400, Stefan Monnier wrote: > Hi Alan, > We're getting to the last few remaining ELisp files in Emacs still using > the old non-lexical dialect, so I looked at converting CC-mode to use > the new dialect as well. AFAICT the code is basically already prepared > for that, tho I did find some minor things in the patch below. OK, it seems this can't be put off any longer. ;-) I've been experimenting with lexical-binding in CC Mode for about two years, now. There's no real advantage in l-b for it, but no real disadvantages, either. The only thing I worry about is that l-b might not work properly in a previous Emacs release (for standalone CC Mode), and there doesn't appear to be a way of switching it on/off according to any criterion. In particular, the following doesn't seem to work, neither in Emacs 25.3 or Emacs 28: -*- eval: (setq lexical-binding (>= emacs-major-version 26)) -*- .. That incantation leaves lexical-binding at nil, regardless of Emacs version. > Of course, the change should be fully backward compatible (i.e. the > code sticks to the common subset of the two dialects). Do closures (for lambda forms) work in Emacs 25 and earlier? > See below the result of my attempt in the form of 4 patches. > 0001 and 0004 are the important ones. 0002 makes the code more regular > (you already use `declare` at various places, so I think it's good to > use it more systematically). 0003 is largely a question of taste (and we > know we don't always agree on that), but I like the warnings it gives me > when a function is marked obsolete or when I make a typo. Thanks. > As usual, take the parts you like, OK, I'll get it done in the next day or two. > Stefan [ .... ] -- Alan Mackenzie (Nuremberg, Germany).