unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: lexical-binding in CC-mode
Date: Tue, 06 Apr 2021 12:49:19 -0400	[thread overview]
Message-ID: <jwvim4ze5qh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <YGyJ/C/ZoMCcHv9b@ACM> (Alan Mackenzie's message of "Tue, 6 Apr 2021 16:19:08 +0000")

> 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




  reply	other threads:[~2021-04-06 16:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 18:38 lexical-binding in CC-mode Stefan Monnier
2021-04-06 16:19 ` Alan Mackenzie
2021-04-06 16:49   ` Stefan Monnier [this message]
2021-04-06 18:42   ` Dmitry Gutov
2021-04-06 20:35     ` Filipp Gunbin
2021-04-10 19:47 ` Alan Mackenzie
2021-04-10 20:21   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvim4ze5qh.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).