comparison runtime/doc/vim9.txt @ 27492:4789f29c9595

Update runtime files Commit: https://github.com/vim/vim/commit/c4573eb12dba6a062af28ee0b8938d1521934ce4 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 31 15:40:56 2022 +0000 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 Jan 2022 16:45:03 +0100
parents 5825405e4e2c
children 063952f68595
comparison
equal deleted inserted replaced
27491:1836c6b25222 27492:4789f29c9595
1 *vim9.txt* For Vim version 8.2. Last change: 2022 Jan 29 1 *vim9.txt* For Vim version 8.2. Last change: 2022 Jan 30
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
370 vim9script 370 vim9script
371 var script_local = 'text' 371 var script_local = 'text'
372 g:global = 'value' 372 g:global = 'value'
373 var Funcref = g:ThatFunction 373 var Funcref = g:ThatFunction
374 374
375 Global functions must be prefixed with "g:" when defining them, but can be 375 Global functions must be prefixed with "g:": >
376 called without "g:". >
377 vim9script 376 vim9script
378 def g:GlobalFunc(): string 377 def g:GlobalFunc(): string
379 return 'text' 378 return 'text'
380 enddef 379 enddef
381 echo GlobalFunc() 380 echo g:GlobalFunc()
382 The "g:" prefix is not needed for auto-load functions. 381 The "g:" prefix is not needed for auto-load functions.
383 382
384 *vim9-function-defined-later* 383 *vim9-function-defined-later*
385 Although global functions can be called without the "g:" prefix, they must 384 Although global functions can be called without the "g:" prefix, they must
386 exist when compiled. By adding the "g:" prefix the function can be defined 385 exist when compiled. By adding the "g:" prefix the function can be defined
1332 variable was declared in a legacy function. 1331 variable was declared in a legacy function.
1333 1332
1334 When a type has been declared this is attached to a list or string. When 1333 When a type has been declared this is attached to a list or string. When
1335 later some expression attempts to change the type an error will be given: > 1334 later some expression attempts to change the type an error will be given: >
1336 var ll: list<number> = [1, 2, 3] 1335 var ll: list<number> = [1, 2, 3]
1337 ll->extend('x') # Error, 'x' is not a number 1336 ll->extend(['x']) # Error, 'x' is not a number
1338 1337
1339 If the type is inferred then the type is allowed to change: > 1338 If the type is inferred then the type is allowed to change: >
1340 [1, 2, 3]->extend('x') # result: [1, 2, 3, 'x'] 1339 [1, 2, 3]->extend(['x']) # result: [1, 2, 3, 'x']
1341 1340
1342 1341
1343 Stricter type checking ~ 1342 Stricter type checking ~
1344 *type-checking* 1343 *type-checking*
1345 In legacy Vim script, where a number was expected, a string would be 1344 In legacy Vim script, where a number was expected, a string would be