[Top][All Lists]

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

Re: How do I pass a variable defined in a wrapping let, to a lambda?

From: tomas
Subject: Re: How do I pass a variable defined in a wrapping let, to a lambda?
Date: Sat, 12 Mar 2022 21:34:57 +0100

On Sat, Mar 12, 2022 at 03:56:24PM -0300, Eduardo Ochs wrote:
> On Sat, 12 Mar 2022 at 10:33, Stefan Monnier <> wrote:
> >
> > Eduardo Ochs [2022-03-12 03:08:04] wrote:
> > > On Sat, 12 Mar 2022 at 01:56, Stefan Monnier via Users list for the
> > > GNU Emacs text editor <> wrote:
> > >> That's right.
> > >> Nowadays, *all* files with a `.el` extension should have
> > >> `-*- lexical-binding:t -*-` somewhere on their first line.
> > >
> > > Or a `-*- lexical-binding:nil -*-`...
> >
> > The only justification I've seen for that so far is for tests that check
> > whether something still works with the old dialect of ELisp (i.e. for
> > files which can simply be deleted the day this old dialect is not
> > supported any more).
> Well, SOME people like dynamic binding very much and they have code
> that would be VERY hard to rewrite in lexical binding...

This reference is actually an argument *for* lexical binding
as a default, which is what -*- lexical-binding:t -*- does.


This one doesn't argue against -*- lexical-binding:t -*- but only
for keeping the possibility of having single dynamically bound
variables (and if you actually read your first reference carefully,
Drew favours "lexical by default, dynamic as an exception", so
definitely not -*- lexical-binding:nil -*-, as you propose.


 "This paper was written by Richard Stallman in 1981 and delivered in
  the ACM Conference on Text Processing."

Perl was born 1988 (seven years later) with dynamic binding (after
all, one of its spiritual parents was the UNIX shell, which also
has dynamic binding). In the meantime it is firmly in the lexical
camp (it keeps dynamic variables, they are useful, but they are
*by far* the exception).

Things have changed since then... a lot.

You can do what the above reference does with closures, which take...
lexical binding. Besides, the closure way is clearer and safer.

You might argue that dynamic binding is useful in some *single*
exceptional cases (this is the position Common Lisp or Perl take;
also the Schemes). But as a default for a whole file... no, you
don't really want that.

You want to put -*- lexical-binding:nil -*- at the top of a file
if you have inherited it and haven't come around to check whether
it will break under the (not anymore so) new discipline.

Note that most well-writen code won't mind which kind of binding
you use.


Attachment: signature.asc
Description: PGP signature

reply via email to

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