Subject: bug#30078: 27.0.50; Use lexical-binding for M-:

From: Stefan Monnier <[email-masked]>
Date: Mon, 19 Mar 2018 16:50:34 -0400

>> lexbind-Elisp language is a strict superset of the
>> dynbind-Elisp language and for that reason I don't see any reason other
>> than backward compatibility to keep dynbind-Elisp.
>> 
>> I'm not trying to fool people by "doing it one subtle step at a time",
>> I'm only trying to make this switch as painless as possible.  I don't
>> yet have a plan for how we'll get rid of dynbind-Elisp and I'm sure
>> it'll take many years and several more steps, some of them less subtle
>> than others.  Some of the steps I could imagine introducing in the not
>> too distant future:
>> - finish converting all Emacs's .el files to use lexical-binding:t.
>> - emit a warning when opening an Elisp file which doesn't specify
>>   `lexical-binding:t' in its local vars.
>> - emit a warning when `eval` is called without a nil 2nd arg.
>
> Really?  Get rid of dynamic binding in ELisp?

Not sure if by "dynamic binding" you mean "the variant of Elisp
corresponding to lexical-binding = nil" (which I call dynbind-Elisp) or
"some new Elisp variant where dynamic binding has been removed
altogether" (which doesn't currently exist AFAIK).

I have no intention to eliminate dynamic binding from Elisp at all.
What I'd like to see happen within the next, say, 20 years is to get rid
of the `lexical-binding` variable (i.e. treat everything as if this var
were always non-nil and as if `eval`s second arg was always non-nil), so
that dynamic binding only ever happens for those variables that have
been explicitly declared to be dynamic with `defvar` (as is the case in
what I call the lexbind-Elisp language).

> Why is that a good idea?

Because, having two languages is a bit inconvenient and brings extra
complexity: e.g. some code snippets only work right in one of the two
languages (usually nowadays it's in the lexbind variant, AFAICT), so you
need to label them appropriately.

> It would mean old code will not run in Emacs for no good reason.

That's true.  Which is why it's a long-term goal only.  Note that it's
usually easy to tweak that code to make it work again, tho it is
occasionally a bit more painful.  And we usually introduce other
backward incompatibilities along the way, so it's rather rare for 20
year old Elisp code to still run correctly unmodified.

>> It's dynamic binding which is the odd one out
> Not for me, it isn't.  Maybe that means _I_ amd the odd one out.

Beside Elisp, I know you're familiar with at least one other language
which only supports lexical scoping: C.
What other language(s) do you know/use?  Which scoping do they support?

        Stefan