Skip to content

Commit 3b8def0

Browse files
committed
Update translation
1 parent 423b3d9 commit 3b8def0

1 file changed

Lines changed: 49 additions & 50 deletions

File tree

doc/vim9.jax

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,115 +2378,113 @@ script と Vim9 script の両方で、辞書以外の値が必要なときに、
23782378
# 文字列のリスト
23792379
echo [1, 2]->map((_, v) => $"#{v}")
23802380
echo [1, 2]->map((_, v) => $"#{v}")->typename()
2381-
# メソッド チェーン内の deepcopy()
2381+
# メソッドチェーン内の deepcopy()
23822382
var mylist = [1, 2]
23832383
echo mylist->deepcopy()->map((_, v) => $"#{v}")
23842384
echo mylist->deepcopy()->map((_, v) => $"#{v}")->typename()
23852385
echo mylist
23862386
<
2387-
The reasoning behind this is, when a type is either declared or inferred
2388-
and the list is passed around and changed, the declaration/inference must
2389-
always hold so that you can rely on the type to match the declared/inferred
2390-
type. For either a list literal or a fully copied list, that type safety is
2391-
not needed because the original list is unchanged (as "echo mylist" shows,
2392-
above).
2387+
この理由は、型が宣言または推論され、リストが渡されたり変更されたりする場合、宣
2388+
言/推論は常に成立していなければならないためである。そうすることで、型が宣言/推
2389+
論された型と一致することを保証できる。文字列のリストでも完全にコピーされたリス
2390+
トでも、元のリストは変更されないため、型安全性は必要ない (上記の "echo mylist"
2391+
が示すように)。
23932392

2394-
If the item type was not declared or determined to be "<any>", it will not
2395-
change, even if all items later become the same type. However, when `mapnew()`
2396-
is used, inference means that the new list will reflect the type(s) present.
2397-
For example: >vim9
2393+
項目の型が "<any>" と宣言または決定されていない場合、後ですべての項目が同じ型
2394+
になったとしても、項目の型は変更されない。ただし、`mapnew()` を使用する場合、
2395+
推論とは、新しいリストが既存の型を反映することを意味する。例えば、以下のように
2396+
なる: >vim9
23982397

23992398
vim9script
24002399
# list<any>
2401-
var mylist = [1, '2'] # mixed types, i.e., list<any>
2400+
var mylist = [1, '2'] # 混合型、つまり list<any>
24022401
echo (mylist, mylist->typename()) # ([1, '2'], 'list<any>')
2403-
mylist->map((_, v) => $"item {v}") # all items are now strings
2404-
echo (mylist, mylist->typename()) # both strings, but list<any>
2402+
mylist->map((_, v) => $"item {v}") # では、すべての項目が文字列に
2403+
echo (mylist, mylist->typename()) # なる。両方とも文字列だが、
2404+
# list<any> である
24052405
# mapnew()
24062406
var newlist = mylist->mapnew((_, v) => v)
2407-
echo (newlist, newlist->typename()) # newlist is a list<string>
2407+
echo (newlist, newlist->typename()) # newlist list<string>
24082408
<
2409-
Using |extend()| and |extendnew()| is similar, i.e., a list literal may use
2410-
the former, so, this is okay: >vim9
2409+
|extend()| |extendnew()| の使い方は似ている。つまり、文字列のリストでは前者
2410+
を使用できるので、以下のようにして問題ない: >vim9
24112411

24122412
vim9cmd echo [1, 2]->extend(['3']) # [1, 2, 3]
24132413
<
2414-
whereas, this is not: >vim9
2414+
一方、これはそうではない: >vim9
24152415

24162416
vim9script
24172417
var mylist: list<number> = [1, 2]
24182418
echo mylist->extend(['3']) # E1013: Argument 2: type mismatch
24192419
<
2420-
Using |extendnew()| is needed for extending an existing typed list, except
2421-
where the extension matches the list's type (or it is "any"). For example,
2422-
first extending with an element of the same type, then extending with a
2423-
different type: >vim9
2420+
既存の型付きリストを拡張するには、|extendnew()| を使用する必要がある。ただし、
2421+
拡張がリストの型と一致する場合 (または "any" の場合) は除く。例えば、最初に同
2422+
じ型の要素で拡張し、次に異なる型で拡張する場合である: >vim9
24242423

24252424
vim9script
24262425
var mylist: list<number> = [1, 2]
24272426
mylist->extend([3])
24282427
echo mylist->extendnew(['4']) # [1, 2, 3, '4']
24292428

24302429
< *E1158*
2431-
Using |flatten()| is not allowed in Vim9 script, because it is intended
2432-
always to change the type. This even applies to a list literal
2433-
(unlike |map()| and |extend()|). Instead, use |flattennew()|: >vim9
2430+
Vim9 script では |flatten()| の使用は許可されていない。これは常に型を変更する
2431+
ことを意図しているためである。これは文字列のリストにも適用される (|map()|
2432+
|extend()| とは異なる)。代わりに |flattennew()| を使用すること: >vim9
24342433

24352434
vim9cmd [1, [2, 3]]->flatten() # E1158: Cannot use flatten
24362435
vim9cmd echo [1, [2, 3]]->flattennew() # [1, 2, 3]
24372436
<
2438-
Assigning to a funcref with specified arguments (see |vim9-func-declaration|)
2439-
involves strict type checking of the arguments. For example, this works: >vim9
2437+
指定された引数 (|vim9-func-declaration| 参照) を持つ関数参照への代入は、引数の
2438+
厳密な型チェックを伴う。例えば、以下のように記述する: >vim9
24402439

24412440
vim9script
24422441
var F_name_age: func(string, number): string
24432442
F_name_age = (n: string, a: number): string => $"Name: {n}, Age: {a}"
24442443
echo F_name_age('Bob', 42)
24452444
<
2446-
whereas this fails with error |E1012| (type mismatch): >vim9
2445+
一方、これはエラー |E1012| (型の不一致) で失敗する: >vim9
24472446

24482447
vim9script
24492448
var F_name_age: func(string, number): string
24502449
F_name_age = (n: string, a: string): string => $"Name: {n}, Age: {a}"
24512450
<
2452-
If there is a variable number of arguments they must have the same type, as in
2453-
this example: >vim9
2451+
引数の数が可変である場合、以下の例のように、引数は同じ型である必要がある: >vim9
24542452

24552453
vim9script
24562454
var Fproduct: func(...list<number>): number
24572455
Fproduct = (...v: list<number>): number => reduce(v, (a, b) => a * b)
2458-
echo Fproduct(3, 2, 4) # Echoes 24
2456+
echo Fproduct(3, 2, 4) # 24 を表示
24592457
<
2460-
And <any> may be used to accommodate mixed types: >vim9
2458+
また、混合型に対応するために <any> を使用することもできる: >vim9
24612459

24622460
vim9script
24632461
var FlatSort: func(...list<any>): any
24642462
FlatSort = (...v: list<any>) => flattennew(v)->sort('n')
2465-
echo FlatSort(true, [[[5, 3], 2], 4]) # Echoes [true, 2, 3, 4, 5]
2463+
echo FlatSort(true, [[[5, 3], 2], 4]) # [true, 2, 3, 4, 5] を表示
24662464
<
2467-
Note: Using <any> in a lambda does not avoid type checking of the
2468-
funcref. It remains constrained by the declared funcref's
2469-
type and, as these examples show, a runtime or compiling error
2470-
occurs when the types mismatch: >vim9
2465+
Note: lambda 式で <any> を使用しても、funcref の型チェックは回避され
2466+
ない。宣言された funcref の型によって制約され、以下の例に示す
2467+
ように、型が一致しない場合は実行時エラーまたはコンパイルエラー
2468+
が発生する: >vim9
24712469

24722470
vim9script
24732471
var FuncSN: func(string): number
24742472
FuncSN = (v: any): number => v->str2nr()
2475-
echo FuncSN('162')->nr2char() # Echoes ¢
2473+
echo FuncSN('162')->nr2char() # ¢ を表示
24762474
echo FuncSN(162)->nr2char()) # E1013 (runtime error)
24772475
< >vim9
24782476
vim9script
24792477
var FuncSN: func(string): number
24802478
FuncSN = (v: any): number => v->str2nr()
24812479
def FuncSNfail(): void
2482-
echo FuncSN('162')->nr2char() # No echo because ...
2483-
echo FuncSN(162)->nr2char() # Error while compiling
2480+
echo FuncSN('162')->nr2char() # 表示されないのは...
2481+
echo FuncSN(162)->nr2char() # コンパイルエラーの為
24842482
enddef
24852483
FuncSNfail()
24862484
<
2487-
When the funcref has no arguments specified, there is no type checking. This
2488-
example shows FlexArgs has a string argument the first time and a list the
2489-
following time: >vim9
2485+
funcref に引数が指定されていない場合、型チェックは行われない。この例では、
2486+
FlexArgs が最初に文字列引数を受け取り、次にリスト引数を受け取ることを示してい
2487+
: >vim9
24902488

24912489
vim9script
24922490
var FlexArgs: func: string
@@ -2495,13 +2493,14 @@ following time: >vim9
24952493
FlexArgs = (...values: list<string>): string => join(values, ', ')
24962494
echo FlexArgs('3', '2', '1', 'GO!')
24972495
<
2498-
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221* *E1222*
2499-
*E1223* *E1224* *E1225* *E1226* *E1228* *E1235* *E1238*
2500-
*E1251* *E1253* *E1256* *E1297* *E1298* *E1301* *E1528*
2501-
*E1529* *E1530* *E1531* *E1534*
2502-
Types are checked for most builtin functions to make it easier to spot
2503-
mistakes. The following one-line |:vim9| commands, calling builtin functions,
2504-
demonstrate many of those type-checking errors: >vim9
2496+
*E1211* *E1217* *E1218* *E1219* *E1220*
2497+
*E1221* *E1222* *E1223* *E1224* *E1225*
2498+
*E1226* *E1228* *E1235* *E1238* *E1251*
2499+
*E1253* *E1256* *E1297* *E1298* *E1301*
2500+
*E1528* *E1529* *E1530* *E1531* *E1534*
2501+
ほとんどの組み込み関数では、型チェックが行われており、間違いを見つけやすくなっ
2502+
ている。以下の |:vim9| という 1 行のコマンドは、組み込み関数を呼び出すもので、
2503+
型チェックエラーの多くを示している: >vim9
25052504

25062505
vim9 9->list2blob() # E1211: List required for argument 1
25072506
vim9 9->ch_close() # E1217: Channel or Job required for

0 commit comments

Comments
 (0)