Conversation
Contributor
|
Thanks for doing this. I was actually thinking about this, since I was working with Javascript. And the ":const" command was available. |
Member
|
Fixed by 8.1.1539. |
Contributor
Author
|
Thank you for your quick review and merge! |
Contributor
|
@brammool
Thank you for your quick review and merge!
My name (Ryuichi Hayashida) seems missing in the patch 8.1.1539. Would
you like to keep adding it at Vim 8.2 release note at
`runtime/doc/version8.txt` in your mind?
Will do. I didn't see your name on github.
I'll also reference the pull request, somehow that was missing (Ken
closed the pull request manually).
…--
hundred-and-one symptoms of being an internet addict:
200. You really believe in the concept of a "paperless" office.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Contributor
Author
@brammool Thank you for your kind consideration. And I'm sorry that I forgot to show my name in advance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi all,
This PR has proposed adding
:constcommand to Vim.Problem
Scope of variables in Vim script function is very dynamic.
This sometimes causes a bug by modifying variables unexpectedly. To prevent this, (if
iis intended not to be modified,):lockvaris effective:However, using
:letand:lockvarhas following downsides::lockvarat everywhere it is required:letand:lockvarmay not be efficient because it introduces overhead of one more command.Solution
In JavaScript,
constis provided for defining a variable.:constdoes the similar thing in Vim script. With it, above example can be written as follows:Here
:constis used instead of:let.:constinternally locks the variablei. Soiis no longer modifiable. And it is more efficient than using both:letand:lockvarbecause both are done in one command.In addition,
:constraises an error if the variable is already existing:So
:constdoes not lock and overwrite existing variable unexpectedly andxis guaranteed to be a new variable.Another use case of
:constwould be defining constants in the script. For example:Here the constant is not intended to be modified any more. So
:constis better than:let.