all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Po Lu <luangruo@yahoo.com>, LdBeth <andpuke@foxmail.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: RE: [External] : Re: Conditional binding and testing of `lexical-binding'
Date: Sun, 2 Jan 2022 23:01:15 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488F2FADCA390B16B26BE80F3489@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <874k6mjomk.fsf@yahoo.com>

> > (static-if (assoc 'lexical-binding (buffer-local-variables))
> >    (provide 'lexical-binding))
> > instead of doing `boundp' test.
> 
> I think it should be runtime, because transferring
> compiled code between Emacs 23 and more recent
> versions is relatively common IME.

My question is about taking advantage of Emacs
support for variable `lexical-binding' when
it's available (which means for Emacs 24+),
while still keeping compatibility for older
Emacs versions.

> >> [The doc just tells you how to convert code to
> >> use lexical binding.  I see nothing about how
> >> to code compatibly for old and new Emacs.]
> 
> +1, there should at least be a paragraph or two
> in the Lisp reference manual about that.

I suspect that this was left out or neglected
(un oublie) due to not thinking of developers
of 3rd-party code that intends to work with
multiple Emacs versions, including some with
and some without `lexical-binding' support.

I can only guess that such a use case just
hasn't occurred to whoever coded variable
`lexical-binding' in Emacs.

> OTOH, I don't think there's much to be gained
> by using lexical binding at all in code that's
> supposed to be compatible with versions of Emacs
> without lexical binding.
> 
> It's not that important.

I fear you're maybe not getting it.

Not all of the code in a given library needs
to be usable in each Emacs version that the
library is compatible with.

And sure, even for that code that is to be
usable both with and without lexical binding,
there's generally no _need_ to use it.

On the other hand, there's generally some
advantage to using it.  I mentioned as much
in the simple example I gave - the drawback
of returning a list with `lambda' car,
instead of returning an actual anonymous
function, is minor.

I didn't ask whether I should try to have
such compatibility in a library.  I asked
what the best way to do so is.  I mentioned
how I intend to do it, and asked for advice
about that (alternative ways, a better way).



  parent reply	other threads:[~2022-01-02 23:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 22:24 Conditional binding and testing of `lexical-binding' Drew Adams
2022-01-02 12:36 ` LdBeth
2022-01-02 12:41   ` Po Lu
2022-01-02 18:29     ` Stefan Monnier
2022-01-02 23:01       ` [External] : " Drew Adams
2022-01-02 23:01     ` Drew Adams [this message]
2022-01-03  0:49       ` Po Lu
2022-01-02 23:01   ` Drew Adams
2022-01-03  3:09     ` LdBeth
2022-01-03  3:31       ` Drew Adams
2022-01-02 18:27 ` Stefan Monnier
2022-01-02 23:01   ` [External] : " Drew Adams

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

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

  git send-email \
    --in-reply-to=SJ0PR10MB5488F2FADCA390B16B26BE80F3489@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=andpuke@foxmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.