comparison runtime/doc/vim9.txt @ 19968:1908e92b02fd

Update runtime files Commit: https://github.com/vim/vim/commit/d1caa941d876181aae0ebebc6ea954045bf0da24 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 10 22:10:56 2020 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Fri, 10 Apr 2020 22:15:05 +0200
parents bd4f91762d0f
children 844c7646f61b
comparison
equal deleted inserted replaced
19967:f11b9ed4f9e1 19968:1908e92b02fd
1 *vim9.txt* For Vim version 8.2. Last change: 2020 Apr 03 1 *vim9.txt* For Vim version 8.2. Last change: 2020 Apr 09
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
117 declaration. An exception is global variables: these can be both used with 117 declaration. An exception is global variables: these can be both used with
118 and without `:let`, because there is no rule about where they are declared. 118 and without `:let`, because there is no rule about where they are declared.
119 119
120 Variables cannot shadow previously defined variables. 120 Variables cannot shadow previously defined variables.
121 Variables may shadow Ex commands, rename the variable if needed. 121 Variables may shadow Ex commands, rename the variable if needed.
122
123 Global variables must be prefixed with "g:", also at the script level.
124 However, global user defined functions are used without "g:". >
125 vim9script
126 let script_local = 'text'
127 let g:global = 'value'
128 let Funcref = ThatFunction
122 129
123 Since "&opt = value" is now assigning a value to option "opt", ":&" cannot be 130 Since "&opt = value" is now assigning a value to option "opt", ":&" cannot be
124 used to repeat a `:substitute` command. 131 used to repeat a `:substitute` command.
125 132
126 133
154 have cyclic dependencies between functions. It is slightly less efficient, 161 have cyclic dependencies between functions. It is slightly less efficient,
155 since the function has to be looked up by name. And a typo in the function 162 since the function has to be looked up by name. And a typo in the function
156 name will only be found when the call is executed. 163 name will only be found when the call is executed.
157 164
158 165
166 Omitting function() ~
167
168 A user defined function can be used as a function reference in an expression
169 without `function()`. The argument types and return type will then be checked.
170 The function must already have been defined. >
171
172 let Funcref = MyFunction
173
174 When using `function()` the resulting type is "func", a function with any
175 number of arguments and any return type. The function can be defined later.
176
177
159 No curly braces expansion ~ 178 No curly braces expansion ~
160 179
161 |curly-braces-names| cannot be used. 180 |curly-braces-names| cannot be used.
162 181
163 182
211 float non-zero 230 float non-zero
212 string non-empty 231 string non-empty
213 blob non-empty 232 blob non-empty
214 list non-empty (different from JavaScript) 233 list non-empty (different from JavaScript)
215 dictionary non-empty (different from JavaScript) 234 dictionary non-empty (different from JavaScript)
216 func when not NULL 235 func when there is a function name
217 partial when not NULL
218 special v:true 236 special v:true
219 job when not NULL 237 job when not NULL
220 channel when not NULL 238 channel when not NULL
221 class when not NULL 239 class when not NULL
222 object when not NULL (TODO: when isTrue() returns v:true) 240 object when not NULL (TODO: when isTrue() returns v:true)
299 list<{type}> 317 list<{type}>
300 dict<{type}> 318 dict<{type}>
301 job 319 job
302 channel 320 channel
303 func 321 func
322 func: {type}
304 func({type}, ...) 323 func({type}, ...)
305 func({type}, ...): {type} 324 func({type}, ...): {type}
306 325
307 Not supported yet: 326 Not supported yet:
308 tuple<a: {type}, b: {type}, ...> 327 tuple<a: {type}, b: {type}, ...>
316 efficient implementation is used that avoids allocating lot of small pieces of 335 efficient implementation is used that avoids allocating lot of small pieces of
317 memory. 336 memory.
318 337
319 A partial and function can be declared in more or less specific ways: 338 A partial and function can be declared in more or less specific ways:
320 func any kind of function reference, no type 339 func any kind of function reference, no type
321 checking 340 checking for arguments or return value
322 func: {type} any number and type of arguments with specific 341 func: {type} any number and type of arguments with specific
323 return type 342 return type
324 func({type} ...) function with argument types, does not return 343 func({type}) function with argument type, does not return
325 a value 344 a value
326 func({type} ...): {type} function with argument types and return type 345 func({type}): {type} function with argument type and return type
346 func(?{type}) function with type of optional argument, does
347 not return a value
348 func(...{type}) function with type of variable number of
349 arguments, does not return a value
350 func({type}, ?{type}, ...{type}): {type}
351 function with:
352 - type of mandatory argument
353 - type of optional argument
354 - type of variable number of arguments
355 - return type
327 356
328 If the return type is "void" the function does not return a value. 357 If the return type is "void" the function does not return a value.
329 358
330 The reference can also be a |Partial|, in which case it stores extra arguments 359 The reference can also be a |Partial|, in which case it stores extra arguments
331 and/or a dictionary, which are not visible to the caller. Since they are 360 and/or a dictionary, which are not visible to the caller. Since they are