Bedrock now uses the lexical-binding: t cookie in all its .el files.
This is the right thing to do if you wrote your .el files recently and assumed lexical-binding was true and you understand the implications thereof.
OTOH if your .el files are older and written before lexical binding was possible, it's best to set the cookies of those files to nil. Or go over them with a fine-toothed comb and rewrite them (if necessary) for lexical binding.
Isn’t lexical binding the default in more or less all other programming languages?
So for people who don’t understand the implications, and wrote their .el files recently, lexical binding is likely less surprising behavior than the alternative?
Absolutely correct! I find dynamic binding quite annoying in the modern era; it can cause subtle and unexpected errors. Common Lisp switched mainstream Lisp programmers over to lexical binding in the 1980s. Scheme had used it from day one. But Emacs dragged its feet for decades.
In the past I wrote my .el files assuming dynamic binding because lexical binding was not available. Until I have the time and inclination to rewrite that code I mark them with
lexical-binding: nil
because that was the assumption under which they were written. If you blindly set
lexical-binding: t
at the top of all your old .el files you're likely to cause errors if that code depended on dynamic binding, e.g. the 'getx' function here:
Comments
This is the right thing to do if you wrote your .el files recently and assumed lexical-binding was true and you understand the implications thereof.
OTOH if your .el files are older and written before lexical binding was possible, it's best to set the cookies of those files to nil. Or go over them with a fine-toothed comb and rewrite them (if necessary) for lexical binding.
Isn’t lexical binding the default in more or less all other programming languages?
So for people who don’t understand the implications, and wrote their .el files recently, lexical binding is likely less surprising behavior than the alternative?
Absolutely correct! I find dynamic binding quite annoying in the modern era; it can cause subtle and unexpected errors. Common Lisp switched mainstream Lisp programmers over to lexical binding in the 1980s. Scheme had used it from day one. But Emacs dragged its feet for decades.
In the past I wrote my .el files assuming dynamic binding because lexical binding was not available. Until I have the time and inclination to rewrite that code I mark them with
because that was the assumption under which they were written. If you blindly set at the top of all your old .el files you're likely to cause errors if that code depended on dynamic binding, e.g. the 'getx' function here:https://www.gnu.org/software/emacs/manual/html_node/elisp/Le...