Mercurial > vim
comparison runtime/doc/vim9.txt @ 19481:c27837cbe922 v8.2.0298
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Commit: https://github.com/vim/vim/commit/0c6ceaf90389b41545d803458c4813013811c756
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 22 18:36:32 2020 +0100
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Problem: Vim9 script: cannot start command with a string constant.
Solution: Recognize expression starting with '('.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Feb 2020 18:45:04 +0100 |
parents | b09afbebffee |
children | a7a24d06d7ce |
comparison
equal
deleted
inserted
replaced
19480:341343c30a23 | 19481:c27837cbe922 |
---|---|
129 Functions can be called without `:call`: > | 129 Functions can be called without `:call`: > |
130 writefile(lines, 'file') | 130 writefile(lines, 'file') |
131 Using `:call` is still possible, but this is discouraged. | 131 Using `:call` is still possible, but this is discouraged. |
132 | 132 |
133 A method call without `eval` is possible, so long as the start is an | 133 A method call without `eval` is possible, so long as the start is an |
134 identifier or can't be an Ex command. It does not work for string constants: > | 134 identifier or can't be an Ex command. It does NOT work for string constants: > |
135 myList->add(123) " works | 135 myList->add(123) " works |
136 g:myList->add(123) " works | 136 g:myList->add(123) " works |
137 [1, 2, 3]->Process() " works | 137 [1, 2, 3]->Process() " works |
138 #{a: 1, b: 2}->Process() " works | 138 #{a: 1, b: 2}->Process() " works |
139 {'a': 1, 'b': 2}->Process() " works | 139 {'a': 1, 'b': 2}->Process() " works |
140 "foobar"->Process() " does NOT work | 140 "foobar"->Process() " does NOT work |
141 eval "foobar"->Process() " works | 141 ("foobar")->Process() " works |
142 'foobar'->Process() " does NOT work | |
143 ('foobar')->Process() " works | |
142 | 144 |
143 In case there is ambiguity between a function name and an Ex command, use ":" | 145 In case there is ambiguity between a function name and an Ex command, use ":" |
144 to make clear you want to use the Ex command. For example, there is both the | 146 to make clear you want to use the Ex command. For example, there is both the |
145 `:substitute` command and the `substitute()` function. When the line starts | 147 `:substitute` command and the `substitute()` function. When the line starts |
146 with `substitute(` this will use the function, prepend a colon to use the | 148 with `substitute(` this will use the function, prepend a colon to use the |
147 command instead: > | 149 command instead: > |
148 :substitute(pattern(replacement( | 150 :substitute(pattern (replacement ( |
149 | 151 |
150 | 152 |
151 No curly braces expansion ~ | 153 No curly braces expansion ~ |
152 | 154 |
153 |curly-braces-names| cannot be used. | 155 |curly-braces-names| cannot be used. |