comparison runtime/doc/vim9.txt @ 23047:29c5f168c6fd

Update runtime files Commit: https://github.com/vim/vim/commit/23515b4ef7580af8b9d3b964a558ab2007cacda5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 29 14:36:24 2020 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 29 Nov 2020 14:45:04 +0100
parents e7c125224b1a
children 285cde4b8d0e
comparison
equal deleted inserted replaced
23046:9a30b28b8154 23047:29c5f168c6fd
1 *vim9.txt* For Vim version 8.2. Last change: 2020 Nov 20 1 *vim9.txt* For Vim version 8.2. Last change: 2020 Nov 25
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
385 var result = start + print 385 var result = start + print
386 386
387 This will assign "start" and print a line: > 387 This will assign "start" and print a line: >
388 var result = start 388 var result = start
389 :+ print 389 :+ print
390
391 Note that the colon is not required for the |+cmd| argument: >
392 edit +6 fname
390 393
391 It is also possible to split a function header over multiple lines, in between 394 It is also possible to split a function header over multiple lines, in between
392 arguments: > 395 arguments: >
393 def MyFunc( 396 def MyFunc(
394 text: string, 397 text: string,
1120 Legacy Vim script uses `:let` for every assignment, while in Vim9 declarations 1123 Legacy Vim script uses `:let` for every assignment, while in Vim9 declarations
1121 are used. That is different, thus it's good to use a different command: 1124 are used. That is different, thus it's good to use a different command:
1122 `:var`. This is used in many languages. The semantics might be slightly 1125 `:var`. This is used in many languages. The semantics might be slightly
1123 different, but it's easily recognized as a declaration. 1126 different, but it's easily recognized as a declaration.
1124 1127
1125 Using `:const` for constants is common, but the semantics vary. Some 1128 Using `:const` for constants is common, but the semantics varies. Some
1126 languages only make the variable immutable, others also make the value 1129 languages only make the variable immutable, others also make the value
1127 immutable. Since "final" is well known from Java for only making the variable 1130 immutable. Since "final" is well known from Java for only making the variable
1128 immutable we decided to use that. And then `:const` can be used for making 1131 immutable we decided to use that. And then `:const` can be used for making
1129 both immutable. This was also used in legacy Vim script and the meaning is 1132 both immutable. This was also used in legacy Vim script and the meaning is
1130 almost the same. 1133 almost the same.
1180 number is non-zero. This is unexpected and often leads to mistakes, since 1183 number is non-zero. This is unexpected and often leads to mistakes, since
1181 text not starting with a number would be converted to zero, which is 1184 text not starting with a number would be converted to zero, which is
1182 considered false. Thus using a string for a condition would often not give an 1185 considered false. Thus using a string for a condition would often not give an
1183 error and be considered false. That is confusing. 1186 error and be considered false. That is confusing.
1184 1187
1185 In Vim9 type checking is more strict to avoid mistakes. Where a condition is 1188 In Vim9 type checking is stricter to avoid mistakes. Where a condition is
1186 used, e.g. with the `:if` command and the `||` operator, only boolean-like 1189 used, e.g. with the `:if` command and the `||` operator, only boolean-like
1187 values are accepted: 1190 values are accepted:
1188 true: `true`, `v:true`, `1`, `0 < 9` 1191 true: `true`, `v:true`, `1`, `0 < 9`
1189 false: `false`, `v:false`, `0`, `0 > 9` 1192 false: `false`, `v:false`, `0`, `0 > 9`
1190 Note that the number zero is false and the number one is true. This is more 1193 Note that the number zero is false and the number one is true. This is more