From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: lexical-binding in CC-mode Date: Tue, 06 Apr 2021 12:49:19 -0400 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="5060"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Tue Apr 06 18:50:07 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 1lTotx-0001C9-T8 for sf-cc-mode-help@m.gmane-mx.org; Tue, 06 Apr 2021 18:50:06 +0200 Original-Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lTotn-0004gM-O8; Tue, 06 Apr 2021 16:49:55 +0000 Original-Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTotl-0004gD-Qw for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 16:49:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:In-Reply-To:Date: References:Message-ID:Subject:Cc:To:From: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=ol60XX5zJDgBWXNS31Af8zgMhn8HMr84PR510mDhra4=; b=igBS+11Nmv/Lp+jU0aRC4W1dW jY5pTBUg0WJpqae3x6NsKoxybe76KQQci/7qM8j0TdfNBwZbzZXHkRmqy8iIkHu3rhX7qJ21OvFuf Km84NgdeojGXlFChHePsNt+7QHPZat8ibAKbsqCrDKbLdpg3so6f8LnUerY+tHf5CS554=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:In-Reply-To:Date:References:Message-ID:Subject: Cc:To:From: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=ol60XX5zJDgBWXNS31Af8zgMhn8HMr84PR510mDhra4=; b=hTiU4Ocf8POAT/jc413SF1NLZl 6o8SDq55yWmfdVE5Q6J5qzLzlLEjZExBq1FQjMV+oJqHtPCdChwixnB4Rc6IqhxdX0dMRTEx2unS+ Rv3tnw7+76hVAbOOefcw4FKlxOMcPsnslYUx47koVDDp6DlCEKDkR7ndZntJSiusExzQ=; Original-Received: from eggs.gnu.org ([209.51.188.92]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lTotZ-00030A-UA for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 16:49:53 +0000 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:54205) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTotR-0005Dc-4A for cc-mode-help@lists.sourceforge.net; Tue, 06 Apr 2021 12:49:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46816) by fencepost.gnu.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lTotP-0004uF-94 for bug-cc-mode@gnu.org; Tue, 06 Apr 2021 12:49:32 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8891) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTotM-0005Bo-11; Tue, 06 Apr 2021 12:49:31 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5D819803F1; Tue, 6 Apr 2021 12:49:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B4F7E803D6; Tue, 6 Apr 2021 12:49:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1617727760; bh=C2B4rJdqXzoPHh4E+oSlL7ospaPwdhwHJu8nlf33cVs=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=g8D1inMhB4nPYhbhj5zAQbTSoPx0iZg0fVcWpntD3WWfmqiWx2fiOkqXMqo5t2m7d syUgi/HDJZk/ZulXcDRIT8oeDgvQQtBvj3mHsg3m3jXDsj1M/RpuKX0CdHitU1YHEt w3D3hzuXfujZg2madHDGwQR36Q0s9nBINSwEtPE/qO75NKLf69xYLH+MLhfVF0aZNX qca6oO8fmV8lb/I9aGetTUSaFIqf8r70n9z/9Mx3yxtIpiwJNk76o3A80FTPT6lps8 3G/kiO07KDKN8wdvYKp5i7eja13WWNZZF6lPf1csCDHmhdce8SRCuUHUOVxyI+i1FH xwDxO6OhjyNxA== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3FBF51203B2; Tue, 6 Apr 2021 12:49:20 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Tue, 6 Apr 2021 16:19:08 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Headers-End: 1lTotZ-00030A-UA 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:8203 gmane.emacs.devel:267484 Archived-At: > 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. Indeed, there's no such thing. As always it's possible to work something out if really needed, but the equivalent of the intended behavior above is pretty cumbersome to obtain, so in all likelihood if a need for something like this comes up, we'd want to find a different workaround (e.g. by changing the code). >> 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? Yes, they do. There have a been a few changes that can impact compatibility, but they've been rather minor. The only ones I can think of are: - performance (IIRC both for `condition-case` and for `unwind-protect`, the performance of lexical code was slightly improved in Emacs-25, and the cost of closure-creation ). - `defun` could not refer to surrounding lexical variables in Emacs<24.3. It's rare to nest `defun` within a `let` or another function, so it only affects very rare cases and these can be rewritten to use `defalias+lambda` if needed. - I think there were a few bugs where macros could not rely on the value of `lexical-binding` to know if the returned code would be using the lexical dialect or not and these were fixed sometime before Emacs-25. That's only relevant for the rare macros which want to generate different code for the different dialects (in most cases it's used to signal an error when the generated code only works with lexical-binding). So I'm quite hopeful that there won't be any backward compatibility issue for CC-mode in this respect. Setfan