Skip to content

Commit a2ac18e

Browse files
authored
Merge pull request #1373 from vim-jp/hh-update-vim9
Update vim9.{txt,jax}
2 parents f7554e0 + ffc07f1 commit a2ac18e

File tree

2 files changed

+59
-17
lines changed

2 files changed

+59
-17
lines changed

doc/vim9.jax

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*vim9.txt* For Vim バージョン 9.0. Last change: 2023 Jun 10
1+
*vim9.txt* For Vim バージョン 9.0. Last change: 2023 Oct 23
22

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

@@ -260,8 +260,8 @@ Vim9 script でスクリプト直下に `:function` や `:def` を使って関
260260
< *E1058* *E1075*
261261
`:def` で定義される関数内で `:function``:def` でネストした関数を名前空間の
262262
指定なしに作成したときは、ネストした関数はその関数が定義されたブロックにローカ
263-
ルな関数になります。またその関数は `function()` に文字列を用いて渡すことはできず、
264-
その関数自身の参照を渡さなければいけません: >
263+
ルな関数になります。またその関数は `function()` に文字列を用いて渡すことはでき
264+
ず、その関数自身の参照を渡さなければいけません: >
265265
def Outer()
266266
def Inner()
267267
echo 'inner'
@@ -1032,8 +1032,9 @@ falsy か truthy として評価されます。これは JavaScript とほぼ同
10321032
単純型とは、文字列 (string)、数値 (float)、特殊値 (special) と真偽値 (bool) で
10331033
す。他の型では |string()| を使う必要があります。
10341034
*false* *true* *null* *null_blob* *null_channel*
1035-
*null_dict* *null_function* *null_job* *null_list*
1036-
*null_partial* *null_string* *E1034*
1035+
*null_class* *null_dict* *null_function* *null_job*
1036+
*null_list* *null_object* *null_partial* *null_string*
1037+
*E1034*
10371038
Vim9 script では以下の定義済みの値が使えます: >
10381039
true
10391040
false
@@ -1479,7 +1480,7 @@ Note スクリプトレベルにおいて、ループ変数はループの後で
14791480

14801481
配列型はありません。代わりに list<{type}> を使ってください。不変のリストに
14811482
対しては大量の細かいメモリを割り当てするのを避ける効率的な実装が使われます。
1482-
*E1005* *E1007*
1483+
*vim9-func-declaration* *E1005* *E1007*
14831484
部分適用と関数は幾らかの方法で宣言することができます:
14841485
func 任意の種類の関数参照。引数や戻り値への型チェッ
14851486
クはない。
@@ -1494,12 +1495,12 @@ func(): {type} 引数がなく、戻り値の型がある関数。
14941495
func({type}) 引数の型があり、値を返さない関数。
14951496
func({type}): {type} 引数の型と戻り値の型がある関数。
14961497
func(?{type}) 任意の引数の型があり、値を返さない関数。
1497-
func(...{type}) 可変長の引数の型があり、値を返さない関数。
1498-
func({type}, ?{type}, ...{type}): {type}
1498+
func(...list<{type}>) 可変長引数のリストの型で、値を返さない関数。
1499+
func({type}, ?{type}, ...list<{type}>): {type}
14991500
以下をもつ関数:
15001501
- 必須の引数の型
15011502
- 任意の引数の型
1502-
- 可変長引数の型
1503+
- 可変長引数のリストの型
15031504
- 戻り値の型
15041505

15051506
もし戻り値の型が "void" なら、関数は値を返しません。
@@ -1671,6 +1672,25 @@ Vim9 script ではこれは厳格にされています。使われている値
16711672
|flattennew()| を使用します。|flatten()| は常に型を変更することを目的としてい
16721673
るため、Vim9 script では使用できません。
16731674

1675+
引数を指定して funcref に代入すると (|vim9-func-declaration| を参照)、引数の厳
1676+
密な型チェックが行われます。可変数の引数の場合も、型と一致する必要があります:
1677+
>
1678+
var FuncRef: func(string, number, bool): number
1679+
FuncRef = (v1: string, v2: number, v3: bool) => 777 # OK
1680+
FuncRef = (v1: string, v2: number, v3: number) => 777 # エラー!
1681+
# 可変数の引数は同じ型でなければならない
1682+
var FuncVA: func(...list<string>): number
1683+
FuncVA = (...v: list<number>): number => v # エラー!
1684+
FuncVA = (...v: list<any>): number => v # OK, `any` ランタイム確認
1685+
FuncVA = (v1: string, v: string2): number => 333 # エラー!
1686+
FuncVA = (v: list<string>): number => 3 # エラー!
1687+
1688+
宛先関数参照に引数が指定されていない場合、引数の型のチェックは行われません: >
1689+
var FuncUnknownArgs: func: number
1690+
FuncUnknownArgs = (v): number => v # OK
1691+
FuncUnknownArgs = (v1: string, v2: string): number => 3 # OK
1692+
FuncUnknownArgs = (...v1: list<string>): number => 333 # OK
1693+
<
16741694
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
16751695
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
16761696
*E1228* *E1238* *E1250* *E1251* *E1252* *E1256*

en/vim9.txt

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*vim9.txt* For Vim version 9.0. Last change: 2023 Jun 10
1+
*vim9.txt* For Vim version 9.0. Last change: 2023 Oct 23
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1025,8 +1025,9 @@ always converted to string: >
10251025
Simple types are Number, Float, Special and Bool. For other types |string()|
10261026
should be used.
10271027
*false* *true* *null* *null_blob* *null_channel*
1028-
*null_dict* *null_function* *null_job* *null_list*
1029-
*null_partial* *null_string* *E1034*
1028+
*null_class* *null_dict* *null_function* *null_job*
1029+
*null_list* *null_object* *null_partial* *null_string*
1030+
*E1034*
10301031
In Vim9 script one can use the following predefined values: >
10311032
true
10321033
false
@@ -1468,7 +1469,7 @@ return value) results in error *E1031* *E1186* .
14681469
There is no array type, use list<{type}> instead. For a list constant an
14691470
efficient implementation is used that avoids allocating a lot of small pieces
14701471
of memory.
1471-
*E1005* *E1007*
1472+
*vim9-func-declaration* *E1005* *E1007*
14721473
A partial and function can be declared in more or less specific ways:
14731474
func any kind of function reference, no type
14741475
checking for arguments or return value
@@ -1487,13 +1488,14 @@ func({type}) function with argument type, does not return
14871488
func({type}): {type} function with argument type and return type
14881489
func(?{type}) function with type of optional argument, does
14891490
not return a value
1490-
func(...{type}) function with type of variable number of
1491-
arguments, does not return a value
1492-
func({type}, ?{type}, ...{type}): {type}
1491+
(...list<{type}>) function with type of list for variable number
1492+
of arguments, does not return a value
1493+
func({type}, ?{type}, ...list<{type}>): {type}
14931494
function with:
14941495
- type of mandatory argument
14951496
- type of optional argument
1496-
- type of variable number of arguments
1497+
- type of list for variable number of
1498+
arguments
14971499
- return type
14981500

14991501
If the return type is "void" the function does not return a value.
@@ -1669,6 +1671,26 @@ Same for |extend()|, use |extendnew()| instead, and for |flatten()|, use
16691671
|flattennew()| instead. Since |flatten()| is intended to always change the
16701672
type, it can not be used in Vim9 script.
16711673

1674+
Assigning to a funcref with specified arguments (see |vim9-func-declaration|)
1675+
does strict type checking of the arguments. For variable number of arguments
1676+
the type must match: >
1677+
var FuncRef: func(string, number, bool): number
1678+
FuncRef = (v1: string, v2: number, v3: bool) => 777 # OK
1679+
FuncRef = (v1: string, v2: number, v3: number) => 777 # Error!
1680+
# variable number of arguments must have same type
1681+
var FuncVA: func(...list<string>): number
1682+
FuncVA = (...v: list<number>): number => v # Error!
1683+
FuncVA = (...v: list<any>): number => v # OK, `any` runtime check
1684+
FuncVA = (v1: string, v: string2): number => 333 # Error!
1685+
FuncVA = (v: list<string>): number => 3 # Error!
1686+
1687+
If the destinataion funcref has no specified arguments, then there is no
1688+
argument type checking: >
1689+
var FuncUnknownArgs: func: number
1690+
FuncUnknownArgs = (v): number => v # OK
1691+
FuncUnknownArgs = (v1: string, v2: string): number => 3 # OK
1692+
FuncUnknownArgs = (...v1: list<string>): number => 333 # OK
1693+
<
16721694
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
16731695
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
16741696
*E1228* *E1238* *E1250* *E1251* *E1252* *E1256*

0 commit comments

Comments
 (0)