In case you haven't been keeping track of progress of the Vim9 script
features, here are two items I would like to highlight.
So far line continuation was indicated by a backslash in the next line.
This was done so that no old Vi command would break. It leads to ugly
code in some places, such as defining a list constant:
let mylist = [
\ 'one',
\ 'two',
\ 'three',
\]
Since in Vim9 script we do not need to be 100% backwards compatible, I
made line continuation work where it could be recognized. That is, if
we run into the end of a line but the command isn't finished yet, we
assume it continues in the next line. This works for a list constant
where we haven't seen the ] yet:
let mylist = [
'one',
'two',
'three',
]
This also works for expressions, so long as it ends in an operator, so
that Vim knows another expression must be following:
let text = header ..
GetMiddle() ..
tail
Inside an expression a comment starting with a double quote is hard to
distinguish from a string constant. Thus in the above example there
cannot be a comment after the ".." operator.
To make it possible to add a comment here we need a different prefix.
Many languages use "#" and that works here as well:
let text = header .. # header comes first
GetMiddle() .. # body
tail # finish
The # character was not used in legacy Vim script, because ":#" is a
valid command. But we don't really need it, ":number" does the same.
One restriction: #{ starts a dictionary, thus that can't be used to
start a comment. We can live with that.
Together this works nicely to comment function arguments:
def MySplitter(
text: string, # what to split
pat: string, # separator pattern
max = -1, # maximum nr of splits
): list<string>
Enjoy!
This is not completely implemented yet, work in progress...
--
BODY: I'm not dead!
CART DRIVER: 'Ere. He says he's not dead.
LARGE MAN: Yes he is.
BODY: I'm not!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202004131938.03DJc4kk015300%40masaka.moolenaar.net.