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

From: Luis Gerhorst <[email-masked]>
Date: Sat, 13 Jan 2018 18:50:36 +0100

> On 12. Jan 2018, at 22:11, Michael Heerdegen <[email-masked]> wrote:
> 
> Ah, so you doubt that lexical-binding once should just be the default.
> Then I think we should discuss about this goal.

Here are a few possible pros of lexical binding:

1) Make Elisp more approachable to newcomers. Lexical binding is the default in most programming languages and thus more people are familiar with it. This makes it easier for people to understand existing code since they don‘t have to get used to implicit dynamic binding first, which the code may take advantage of.

2) Make existing code more maintainable. I was involved in porting the package emacs-eclim to lexical binding. The process shed light on some very dark parts of the codebase nobody had touched in a while since they were written in very bad style and thus hard to understand. Using lexical binding forced us to simplify those parts.

3) This is a minor one: I‘ve heard that lexical binding allows for more optimizations. I don‘t know to which extend this actually happens and whether it is noticeable to the user.

I believe 1) and 2) will significantly help improving the general quality of Elisp code and thus of Emacs in general.

Here‘s the big con:

If lexical binding should become the default one day, you would have to give everyone a reasonable amount of time (multiple years?) to adapt for it and port their code or set lexical binding to nil in their files.

One idea would be to make elisp-mode somehow encourage users to enable lexical binding in the files they are editing. Any ideas how this can be done without annoying users? Ideas:
- Prompting every time elisp-mode is enabled in a file that does not have a lexical binding header.
- I know that certain functions insert a apropriate copyright notice into el-files, do / can those also set lexical binding to t?

Best regards,
Luis