[vim9script/en] corrections and improvements #5438
Open
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.
[language/lang-code]- Yes, the title is, though the commit message is only[vim9script]- I hope that is okay.I envisaged this PR would be small, addressing only the issues noted in 5376. However, while working through them, I came across several other things, and it snowballed into a much larger update.
Header
name, which should be “Vim9 script”. It is the name used consistently in Vim’s documentation (and is corrected by PRs in the Vim repository when not using that form). It is also corrected in the main text where “Vim9script” and “Vim9Script” are also used.)vim9script.md.Style Guidelines / Overview
CONTRIBUTING.md says to, “Try to use as few words as possible”, and, “Code examples are preferred over exposition in all cases.” Accordingly, the 400+ word introduction (and explanation at the start of the monolithic code block) is reduced by two thirds in an introduction that does not:
The Overview, and the numbered sections/sub-sections, separate the code into logical blocks. This follows the approach of a few other
learnxinyminutestopics, e.g., Smalltalk`. Doing this makes more sense in the Vim9 script context:Although the capitalised heading after each
vim9scriptcommand may appear a bit repetitive when looking at the main document online (when the “Get the code:” link is used) the purpose of doing this is revealed. It makes it easy to see what each block is about, and facilitates copy-and-put of the desired code into Vim to source the example(s).Plenty of the content of the big code block in the current
vim9script.mdremains unchanged, though there are some general improvements. Examples:1. Types, Operators, Expressions, and Regular Expressions
The section is divided into six sub-topics:
The section is a bit longer than currently, with more examples in the Strings and Regular Expressions especially, covering points like POSIX bracket expressions and PCRE-style assertions.
It also addresses the “passage of time” matter of tuples, which are no longer a “recent addition”. In the current file, that was a design choice to lessen the likelihood that sourcing the monolithic script would error. With the code now in separate scripts, that is less of a concern.
2. Variables
There are few changes to this section, which is divided into five sub-sections:
3. Control Flow
There are few changes to this section, which is divided into two sub-sections:
4. Functions, Lambdas, and Closures
This section has a few more changes, in the sub-sections:
Improvements:
_argument usage for ignoring unused callback parameters is documented.5. Classes and Enums
Aside from providing two sub-sections, the examples are largely unchanged, though the enum one removes some redundancy.
6. Sourcing Scripts, Modules, and Importing
There are not too many changes to this section, though the division into sub-sections helps particularly as the exporting and importing “files” are more obvious.
7. Vim Idioms
This section is easier to navigate now with sub-sections addressing distinct topics.
8. External Commands
This section is significantly improved. It progresses from simple to more complicated, with all examples now working cross-platform, using commands like
whoamiinstead of Unix-specific, likels. The [now working] job example is completely rewritten to be functional, using proper callbacks with&shelland&shellcmdflagfor portability. The simplified outputs are also less distracting (e.g., avoiding potentially long directory listings).Sub-sections are now:
system()systemlist()9. Testing, Debugging, and Inspecting Bytecode
The separation into subsections makes sourcing and working interactively with this content meaningful.
Sub-sections now are:
Additional Resources
This is updated and to indicate what is at the destinations for some of the links. It has links relocated from the introduction/in the main text, removing what is currently duplication (e.g., the Python Developers link is prominent in the introduction currently, which is not ideal for a resource aimed at briefly covering off Vim9 script).