Skip to content

Commit 5b6160a

Browse files
authored
Merge pull request #2011 from h-east/update-vim9
Update vim9.{txt,jax}
2 parents ccafd39 + 39a88b2 commit 5b6160a

File tree

2 files changed

+77
-15
lines changed

2 files changed

+77
-15
lines changed

doc/vim9.jax

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*vim9.txt* For Vim バージョン 9.1. Last change: 2025 Mar 06
1+
*vim9.txt* For Vim バージョン 9.1. Last change: 2025 Mar 23
22

33
VIMリファレンスマニュアル by Bram Moolenaar
44

@@ -1006,9 +1006,10 @@ falsy か truthy として評価されます。これは JavaScript とほぼ同
10061006
number 非0
10071007
float 非0
10081008
string 空文字列以外
1009-
blob 空ブロブ以外
1010-
list 空リスト以外 (JavaScript とは異なります)
1011-
dictionary 空辞書以外 (JavaScript とは異なります)
1009+
blob 空 blob 以外
1010+
list 空リスト以外 (JavaScript とは異なる)
1011+
tuple 空 tuple 以外 (JavaScript とは異なる)
1012+
dictionary 空辞書以外 (JavaScript とは異なる)
10121013
func 関数名があるとき
10131014
special true または v:true
10141015
job 非 NULL
@@ -1055,6 +1056,7 @@ Vim9 script では以下の定義済みの値が使えます: >
10551056
null_function
10561057
null_job
10571058
null_list
1059+
null_tuple
10581060
null_object
10591061
null_partial
10601062
null_string
@@ -1480,21 +1482,46 @@ Note スクリプトレベルにおいて、ループ変数はループの後で
14801482
dict<{type}>
14811483
job
14821484
channel
1485+
tuple<{type}>
1486+
tuple<{type}, {type}, ...>
1487+
tuple<...list<{type}>>
1488+
tuple<{type}, ...list<{type}>>
14831489
func
14841490
func: {type}
14851491
func({type}, ...)
14861492
func({type}, ...): {type}
14871493
void
14881494

1489-
まだサポートされていません:
1490-
tuple<a: {type}, b: {type}, ...>
1491-
14921495
これらの型は宣言において使えますが、いかなる単純値も実際に "void" 型を持つこと
14931496
はありません。void (例えば、戻り値のない関数) を使おうとするとエラーがでます。
14941497
*E1031* *E1186*
14951498

14961499
配列型はありません。代わりに list<{type}> を使ってください。不変のリストに
14971500
対しては大量の細かいメモリを割り当てするのを避ける効率的な実装が使われます。
1501+
*tuple-type*
1502+
tuple 型は、多かれ少なかれ具体的な方法で宣言できる:
1503+
tuple<number> |Number| 型の項目を 1 つ含む tuple
1504+
tuple<number, string> |Number||String| の 2 つの項目を含む tuple
1505+
tuple<number, float, bool> |Number||Float| および |Boolean| 型の 3 つの
1506+
項目を含む tuple
1507+
tuple<...list<number>> |Number| 型の 0 個以上の項目を持つ可変長 tuple
1508+
tuple<number, ...list<string>> |Number| 型の項目とそれに続く 0 個以上の
1509+
|String| 型の項目を含む tuple
1510+
1511+
例: >
1512+
var myTuple: tuple<number> = (20,)
1513+
var myTuple: tuple<number, string> = (30, 'vim')
1514+
var myTuple: tuple<number, float, bool> = (40, 1.1, true)
1515+
var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1516+
var myTuple: tuple<number, ...list<string>> = (3, 'a', 'b', 'c')
1517+
<
1518+
*variadic-tuple* *E1539*
1519+
可変長 tuple には、同じ型の 0 個以上の項目が含まれる。可変長 tuple の型はリス
1520+
ト型で終わる必要がある。例: >
1521+
var myTuple: tuple<...list<number>> = (1, 2, 3)
1522+
var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1523+
var myTuple: tuple<...list<bool>> = ()
1524+
<
14981525
*vim9-func-declaration* *E1005* *E1007*
14991526
部分適用と関数は幾らかの方法で宣言することができます:
15001527
func 任意の種類の関数参照。引数や戻り値への型チェッ
@@ -1708,14 +1735,15 @@ Vim9 script ではこれは厳格にされています。使われている値
17081735
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
17091736
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
17101737
*E1228* *E1238* *E1250* *E1251* *E1252* *E1256*
1711-
*E1297* *E1298* *E1301*
1738+
*E1297* *E1298* *E1301* *E1528* *E1529* *E1530*
1739+
*E1531* *E1534*
17121740
間違いを発見しやすくするために、ほとんどの組み込み関数で型がチェックされます。
17131741

17141742
変数のカテゴリー、デフォルトおよび null の扱い ~
17151743
*variable-categories* *null-variables*
17161744
変数には次のカテゴリがあります:
17171745
プリミティブ number, float, boolean
1718-
コンテナ string, blob, list, dict
1746+
コンテナ string, blob, list, tuple, dict
17191747
特殊 function, job, channel, user-defined-object
17201748

17211749
初期化子を使用せずに変数を宣言する場合は、明示的に型を指定する必要があります。
@@ -1847,6 +1875,7 @@ null_<type> に初期化された変数はすべて、null_<type> と等しく
18471875
var s: string s == null
18481876
var b: blob b != null ***
18491877
var l: list<any> l != null ***
1878+
var t: tuple<any> t != null ***
18501879
var d: dict<any> d != null ***
18511880
var f: func f == null
18521881
var j: job j == null
@@ -1857,6 +1886,7 @@ null_<type> に初期化された変数はすべて、null_<type> と等しく
18571886
var s2: string = "" == null_string != null
18581887
var b2: blob = 0z == null_blob != null
18591888
var l2: list<any> = [] == null_list != null
1889+
var t2: tuple<any> = () == null_tuple != null
18601890
var d2: dict<any> = {} == null_dict != null
18611891

18621892
NOTE: ジョブなどの特殊な変数はデフォルトで null 値になり、対応する空の値はあり

en/vim9.txt

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*vim9.txt* For Vim version 9.1. Last change: 2025 Mar 06
1+
*vim9.txt* For Vim version 9.1. Last change: 2025 Mar 23
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1001,6 +1001,7 @@ empty list and dict is falsy:
10011001
string non-empty
10021002
blob non-empty
10031003
list non-empty (different from JavaScript)
1004+
tuple non-empty (different from JavaScript)
10041005
dictionary non-empty (different from JavaScript)
10051006
func when there is a function name
10061007
special true or v:true
@@ -1048,6 +1049,7 @@ In Vim9 script one can use the following predefined values: >
10481049
null_function
10491050
null_job
10501051
null_list
1052+
null_tuple
10511053
null_object
10521054
null_partial
10531055
null_string
@@ -1467,22 +1469,49 @@ The following builtin types are supported:
14671469
dict<{type}>
14681470
job
14691471
channel
1472+
tuple<{type}>
1473+
tuple<{type}, {type}, ...>
1474+
tuple<...list<{type}>>
1475+
tuple<{type}, ...list<{type}>>
14701476
func
14711477
func: {type}
14721478
func({type}, ...)
14731479
func({type}, ...): {type}
14741480
void
14751481

1476-
Not supported yet:
1477-
tuple<a: {type}, b: {type}, ...>
1478-
14791482
These types can be used in declarations, but no simple value will actually
14801483
have the "void" type. Trying to use a void (e.g. a function without a
14811484
return value) results in error *E1031* *E1186* .
14821485

14831486
There is no array type, use list<{type}> instead. For a list constant an
14841487
efficient implementation is used that avoids allocating a lot of small pieces
14851488
of memory.
1489+
*tuple-type*
1490+
A tuple type can be declared in more or less specific ways:
1491+
tuple<number> a tuple with a single item of type |Number|
1492+
tuple<number, string> a tuple with two items of type |Number| and
1493+
|String|
1494+
tuple<number, float, bool> a tuple with three items of type |Number|,
1495+
|Float| and |Boolean|.
1496+
tuple<...list<number>> a variadic tuple with zero or more items of
1497+
type |Number|.
1498+
tuple<number, ...list<string>> a tuple with an item of type |Number| followed
1499+
by zero or more items of type |String|.
1500+
1501+
Examples: >
1502+
var myTuple: tuple<number> = (20,)
1503+
var myTuple: tuple<number, string> = (30, 'vim')
1504+
var myTuple: tuple<number, float, bool> = (40, 1.1, true)
1505+
var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1506+
var myTuple: tuple<number, ...list<string>> = (3, 'a', 'b', 'c')
1507+
<
1508+
*variadic-tuple* *E1539*
1509+
A variadic tuple has zero or more items of the same type. The type of a
1510+
variadic tuple must end with a list type. Examples: >
1511+
var myTuple: tuple<...list<number>> = (1, 2, 3)
1512+
var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1513+
var myTuple: tuple<...list<bool>> = ()
1514+
<
14861515
*vim9-func-declaration* *E1005* *E1007*
14871516
A partial and function can be declared in more or less specific ways:
14881517
func any kind of function reference, no type
@@ -1707,15 +1736,16 @@ argument type checking: >
17071736
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
17081737
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
17091738
*E1228* *E1238* *E1250* *E1251* *E1252* *E1256*
1710-
*E1297* *E1298* *E1301*
1739+
*E1297* *E1298* *E1301* *E1528* *E1529* *E1530*
1740+
*E1531* *E1534*
17111741
Types are checked for most builtin functions to make it easier to spot
17121742
mistakes.
17131743

17141744
Categories of variables, defaults and null handling ~
17151745
*variable-categories* *null-variables*
17161746
There are categories of variables:
17171747
primitive number, float, boolean
1718-
container string, blob, list, dict
1748+
container string, blob, list, tuple, dict
17191749
specialized function, job, channel, user-defined-object
17201750

17211751
When declaring a variable without an initializer, an explicit type must be
@@ -1845,6 +1875,7 @@ An uninitialized variable is usually equal to null; it depends on its type:
18451875
var s: string s == null
18461876
var b: blob b != null ***
18471877
var l: list<any> l != null ***
1878+
var t: tuple<any> t != null ***
18481879
var d: dict<any> d != null ***
18491880
var f: func f == null
18501881
var j: job j == null
@@ -1855,6 +1886,7 @@ A variable initialized to empty equals null_<type>; but not null:
18551886
var s2: string = "" == null_string != null
18561887
var b2: blob = 0z == null_blob != null
18571888
var l2: list<any> = [] == null_list != null
1889+
var t2: tuple<any> = () == null_tuple != null
18581890
var d2: dict<any> = {} == null_dict != null
18591891

18601892
NOTE: the specialized variables, like job, default to null value and have no

0 commit comments

Comments
 (0)