emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: Conditional binding and testing of `lexical-binding


From: Drew Adams
Subject: RE: [External] : Re: Conditional binding and testing of `lexical-binding'
Date: Sun, 2 Jan 2022 23:01:15 +0000

> > (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).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]