-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently left out topic: Use lexical binding. #53
Comments
Example: File
File
Either Compilation rules. Also work repeatedly:
Evaluation:
Result:
This might be unexpected since Note that
In this form, we get again the unexpected result
|
Isn't this the whole point of lexical binding? To bind variables lexically and not overflow to the context of other libraries? Or is this what you are pointing out? I'm a bit confused what the action here should be. |
It is essentially a remainder to put a I stress that because of my own experiences: Missing the About your question:
We have here the opposite case. I tried to indicate that by the package names |
That implies to me that the user here would be aware of the existence of In that case I agree that if the defvar or the import is omited things will not work as expected. I'm not sure if this is a style choice or more of a "FAQ: My code doesn't work" kind of entry. I don't care much either way, it is probably useful to the reader. OTOH, it kind of feels out of scope of a style guide as it's more of a programming rule. |
Thanks for the comment.
The actual style guid line is to use The warning has the most relevance when one changes the scoping of a library from dynamical to lexical. By "work" I mean that the value 1 let-bound to |
Emacs 27.2 will include such a recommendation in its Coding Conventions: |
Nowdays one should use lexical binding for library programming in Elisp. Optimization is better with lexical binding.
The new Section should contain the following warning:
If one uses a special variable from another library in a function one must have either a top-level
defvar
for that variable in the file where it is used or arequire
for the other library at top-level. Otherwiselet
in functions can go terribly wrong for variables that are declared special in other libraries. The lexical binding of that variables is not visible in functions called within thelet
-form.The text was updated successfully, but these errors were encountered: