aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/docs/.vitepress/config.mts7
-rw-r--r--doc/docs/de/doc/advanced/do.md22
-rw-r--r--doc/docs/de/doc/control-flow/for-loop.md16
-rw-r--r--doc/docs/de/doc/control-flow/while-loop.md42
-rw-r--r--doc/docs/de/doc/language-basics/module.md (renamed from doc/docs/de/doc/advanced/module.md)0
-rw-r--r--doc/docs/de/doc/objects/with-statement.md44
-rw-r--r--doc/docs/doc/advanced/do.md22
-rw-r--r--doc/docs/doc/control-flow/for-loop.md18
-rw-r--r--doc/docs/doc/control-flow/while-loop.md42
-rw-r--r--doc/docs/doc/language-basics/module.md (renamed from doc/docs/doc/advanced/module.md)0
-rw-r--r--doc/docs/doc/objects/with-statement.md44
-rw-r--r--doc/docs/id-id/doc/advanced/do.md22
-rw-r--r--doc/docs/id-id/doc/control-flow/for-loop.md16
-rw-r--r--doc/docs/id-id/doc/control-flow/while-loop.md42
-rw-r--r--doc/docs/id-id/doc/language-basics/module.md (renamed from doc/docs/id-id/doc/advanced/module.md)0
-rw-r--r--doc/docs/id-id/doc/objects/with-statement.md44
-rw-r--r--doc/docs/pt-br/doc/advanced/do.md22
-rw-r--r--doc/docs/pt-br/doc/control-flow/for-loop.md16
-rw-r--r--doc/docs/pt-br/doc/control-flow/while-loop.md42
-rw-r--r--doc/docs/pt-br/doc/language-basics/module.md (renamed from doc/docs/pt-br/doc/advanced/module.md)0
-rw-r--r--doc/docs/pt-br/doc/objects/with-statement.md44
-rw-r--r--doc/docs/zh/doc/advanced/do.md22
-rw-r--r--doc/docs/zh/doc/control-flow/for-loop.md16
-rw-r--r--doc/docs/zh/doc/control-flow/while-loop.md42
-rw-r--r--doc/docs/zh/doc/language-basics/module.md (renamed from doc/docs/zh/doc/advanced/module.md)0
-rw-r--r--doc/docs/zh/doc/objects/with-statement.md44
26 files changed, 614 insertions, 15 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts
index cae1d89..c23301f 100644
--- a/doc/docs/.vitepress/config.mts
+++ b/doc/docs/.vitepress/config.mts
@@ -299,6 +299,7 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
299 text: text.attributes, 299 text: text.attributes,
300 link: `${basePath}/language-basics/attributes`, 300 link: `${basePath}/language-basics/attributes`,
301 }, 301 },
302 { text: text.module, link: `${basePath}/language-basics/module` },
302 ], 303 ],
303 }, 304 },
304 { 305 {
@@ -389,7 +390,6 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
389 collapsed: true, 390 collapsed: true,
390 items: [ 391 items: [
391 { text: text.macro, link: `${basePath}/advanced/macro` }, 392 { text: text.macro, link: `${basePath}/advanced/macro` },
392 { text: text.module, link: `${basePath}/advanced/module` },
393 { 393 {
394 text: text.lineDecorators, 394 text: text.lineDecorators,
395 link: `${basePath}/advanced/line-decorators`, 395 link: `${basePath}/advanced/line-decorators`,
@@ -510,6 +510,11 @@ export default defineConfig({
510 document.head.appendChild(s); 510 document.head.appendChild(s);
511})();`, 511})();`,
512 ], 512 ],
513 [
514 "style",
515 {},
516 ".dark .vp-code span{color:var(--shiki-dark,inherit)}html:not(.dark) .vp-code span{color:var(--shiki-light,inherit)}",
517 ],
513 ], 518 ],
514 vite: { 519 vite: {
515 publicDir: resolve(__dirname, "public"), 520 publicDir: resolve(__dirname, "public"),
diff --git a/doc/docs/de/doc/advanced/do.md b/doc/docs/de/doc/advanced/do.md
index 265a5ba..c6c41cf 100644
--- a/doc/docs/de/doc/advanced/do.md
+++ b/doc/docs/de/doc/advanced/do.md
@@ -20,7 +20,27 @@ print var -- nil hier
20 20
21</YueDisplay> 21</YueDisplay>
22 22
23YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. 23YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. `do`-Ausdrücke unterstützen die Verwendung von `break`, um den Kontrollfluss zu unterbrechen und mehrere Rückgabewerte vorzeitig zurückzugeben.
24
25```yuescript
26status, value = do
27 n = 12
28 if n > 10
29 break "large", n
30 break "small", n
31```
32
33<YueDisplay>
34
35```yue
36status, value = do
37 n = 12
38 if n > 10
39 break "large", n
40 break "small", n
41```
42
43</YueDisplay>
24 44
25```yuescript 45```yuescript
26counter = do 46counter = do
diff --git a/doc/docs/de/doc/control-flow/for-loop.md b/doc/docs/de/doc/control-flow/for-loop.md
index 827d983..16b5418 100644
--- a/doc/docs/de/doc/control-flow/for-loop.md
+++ b/doc/docs/de/doc/control-flow/for-loop.md
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
86 86
87</YueDisplay> 87</YueDisplay>
88 88
89Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewert, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet. 89Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewerten, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet. `for`-Ausdrücke unterstützen mehrere `break`-Werte.
90 90
91Beispiel: die erste Zahl größer als 10 finden: 91Beispiel: die erste Zahl größer als 10 finden:
92 92
@@ -106,6 +106,20 @@ first_large = for n in *numbers
106 106
107Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken. 107Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken.
108 108
109```yuescript
110key, score = for k, v in pairs data
111 break k, v * 10 if k == "target"
112```
113
114<YueDisplay>
115
116```yue
117key, score = for k, v in pairs data
118 break k, v * 10 if k == "target"
119```
120
121</YueDisplay>
122
109Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst. 123Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst.
110 124
111`for`-Schleifen am Ende eines Funktionsrumpfs werden nicht in eine Tabelle für einen Rückgabewert gesammelt (stattdessen gibt die Funktion `nil` zurück). Du kannst entweder explizit `return` verwenden oder die Schleife in eine Listen-Comprehension umwandeln. 125`for`-Schleifen am Ende eines Funktionsrumpfs werden nicht in eine Tabelle für einen Rückgabewert gesammelt (stattdessen gibt die Funktion `nil` zurück). Du kannst entweder explizit `return` verwenden oder die Schleife in eine Listen-Comprehension umwandeln.
diff --git a/doc/docs/de/doc/control-flow/while-loop.md b/doc/docs/de/doc/control-flow/while-loop.md
index 6d9f089..98776ec 100644
--- a/doc/docs/de/doc/control-flow/while-loop.md
+++ b/doc/docs/de/doc/control-flow/while-loop.md
@@ -45,7 +45,25 @@ until running == false do my_function!
45 45
46</YueDisplay> 46</YueDisplay>
47 47
48Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden. 48Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. `while`- und `until`-Ausdrücke unterstützen `break` mit mehreren Rückgabewerten.
49
50```yuescript
51value, doubled = while true
52 n = get_next!
53 break n, n * 2 if n > 10
54```
55
56<YueDisplay>
57
58```yue
59value, doubled = while true
60 n = get_next!
61 break n, n * 2 if n > 10
62```
63
64</YueDisplay>
65
66Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden.
49 67
50## Repeat-Schleife 68## Repeat-Schleife
51 69
@@ -70,3 +88,25 @@ until i == 0
70``` 88```
71 89
72</YueDisplay> 90</YueDisplay>
91
92`repeat`-Ausdrücke unterstützen ebenfalls `break` mit mehreren Rückgabewerten:
93
94```yuescript
95i = 1
96value, scaled = repeat
97 break i, i * 100 if i > 3
98 i += 1
99until false
100```
101
102<YueDisplay>
103
104```yue
105i = 1
106value, scaled = repeat
107 break i, i * 100 if i > 3
108 i += 1
109until false
110```
111
112</YueDisplay>
diff --git a/doc/docs/de/doc/advanced/module.md b/doc/docs/de/doc/language-basics/module.md
index f20deec..f20deec 100644
--- a/doc/docs/de/doc/advanced/module.md
+++ b/doc/docs/de/doc/language-basics/module.md
diff --git a/doc/docs/de/doc/objects/with-statement.md b/doc/docs/de/doc/objects/with-statement.md
index adeeda6..f299902 100644
--- a/doc/docs/de/doc/objects/with-statement.md
+++ b/doc/docs/de/doc/objects/with-statement.md
@@ -44,6 +44,50 @@ file = with File "Lieblingsessen.txt"
44 44
45</YueDisplay> 45</YueDisplay>
46 46
47`with`-Ausdrücke unterstützen `break` mit genau einem Wert:
48
49```yuescript
50result = with obj
51 break .value
52```
53
54<YueDisplay>
55
56```yue
57result = with obj
58 break .value
59```
60
61</YueDisplay>
62
63Sobald `break value` in `with` verwendet wird, gibt der `with`-Ausdruck nicht mehr sein Zielobjekt zurück, sondern den von `break` gelieferten Wert.
64
65```yuescript
66a = with obj
67 .x = 1
68-- a ist obj
69
70b = with obj
71 break .x
72-- b ist .x, nicht obj
73```
74
75<YueDisplay>
76
77```yue
78a = with obj
79 .x = 1
80-- a ist obj
81
82b = with obj
83 break .x
84-- b ist .x, nicht obj
85```
86
87</YueDisplay>
88
89Im Unterschied zu `for` / `while` / `repeat` / `do` unterstützt `with` nur einen `break`-Wert.
90
47Oder … 91Oder …
48 92
49```yuescript 93```yuescript
diff --git a/doc/docs/doc/advanced/do.md b/doc/docs/doc/advanced/do.md
index c4b3e30..e13b025 100644
--- a/doc/docs/doc/advanced/do.md
+++ b/doc/docs/doc/advanced/do.md
@@ -22,6 +22,28 @@ print var -- nil here
22 22
23YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. 23YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body.
24 24
25`do` expressions also support using `break` to interrupt control flow and return multiple values early:
26
27```yuescript
28status, value = do
29 n = 12
30 if n > 10
31 break "large", n
32 break "small", n
33```
34
35<YueDisplay>
36
37```yue
38status, value = do
39 n = 12
40 if n > 10
41 break "large", n
42 break "small", n
43```
44
45</YueDisplay>
46
25```yuescript 47```yuescript
26counter = do 48counter = do
27 i = 0 49 i = 0
diff --git a/doc/docs/doc/control-flow/for-loop.md b/doc/docs/doc/control-flow/for-loop.md
index b92e94e..763e6a7 100644
--- a/doc/docs/doc/control-flow/for-loop.md
+++ b/doc/docs/doc/control-flow/for-loop.md
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
86 86
87</YueDisplay> 87</YueDisplay>
88 88
89In addition, for loops support break with a return value, allowing the loop itself to be used as an expression that exits early with a meaningful result. 89In addition, for loops support break with return values, allowing the loop itself to be used as an expression that exits early with meaningful results.
90 90
91For example, to find the first number greater than 10: 91For example, to find the first number greater than 10:
92 92
@@ -106,6 +106,22 @@ first_large = for n in *numbers
106 106
107This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. 107This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions.
108 108
109For loop expressions can break with multiple values:
110
111```yuescript
112key, score = for k, v in pairs data
113 break k, v * 10 if k == "target"
114```
115
116<YueDisplay>
117
118```yue
119key, score = for k, v in pairs data
120 break k, v * 10 if k == "target"
121```
122
123</YueDisplay>
124
109You can also filter values by combining the for loop expression with the continue statement. 125You can also filter values by combining the for loop expression with the continue statement.
110 126
111For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension. 127For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension.
diff --git a/doc/docs/doc/control-flow/while-loop.md b/doc/docs/doc/control-flow/while-loop.md
index 02e82d6..0dff342 100644
--- a/doc/docs/doc/control-flow/while-loop.md
+++ b/doc/docs/doc/control-flow/while-loop.md
@@ -45,7 +45,25 @@ until running == false do my_function!
45 45
46</YueDisplay> 46</YueDisplay>
47 47
48Like for loops, the while loop can also be used an expression. Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned. 48Like for loops, the while loop can also be used as an expression. While and until loop expressions support `break` with multiple return values.
49
50```yuescript
51value, doubled = while true
52 n = get_next!
53 break n, n * 2 if n > 10
54```
55
56<YueDisplay>
57
58```yue
59value, doubled = while true
60 n = get_next!
61 break n, n * 2 if n > 10
62```
63
64</YueDisplay>
65
66Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned.
49 67
50## Repeat Loop 68## Repeat Loop
51 69
@@ -70,3 +88,25 @@ until i == 0
70``` 88```
71 89
72</YueDisplay> 90</YueDisplay>
91
92Repeat loop expressions also support `break` with multiple return values:
93
94```yuescript
95i = 1
96value, scaled = repeat
97 break i, i * 100 if i > 3
98 i += 1
99until false
100```
101
102<YueDisplay>
103
104```yue
105i = 1
106value, scaled = repeat
107 break i, i * 100 if i > 3
108 i += 1
109until false
110```
111
112</YueDisplay>
diff --git a/doc/docs/doc/advanced/module.md b/doc/docs/doc/language-basics/module.md
index 0ba2d90..0ba2d90 100644
--- a/doc/docs/doc/advanced/module.md
+++ b/doc/docs/doc/language-basics/module.md
diff --git a/doc/docs/doc/objects/with-statement.md b/doc/docs/doc/objects/with-statement.md
index 5d7fea3..9173f9c 100644
--- a/doc/docs/doc/objects/with-statement.md
+++ b/doc/docs/doc/objects/with-statement.md
@@ -44,6 +44,50 @@ file = with File "favorite_foods.txt"
44 44
45</YueDisplay> 45</YueDisplay>
46 46
47`with` expressions support `break` with one value:
48
49```yuescript
50result = with obj
51 break .value
52```
53
54<YueDisplay>
55
56```yue
57result = with obj
58 break .value
59```
60
61</YueDisplay>
62
63After `break value` is used inside `with`, the `with` expression no longer returns its target object. Instead, it returns the value from `break`.
64
65```yuescript
66a = with obj
67 .x = 1
68-- a is obj
69
70b = with obj
71 break .x
72-- b is .x, not obj
73```
74
75<YueDisplay>
76
77```yue
78a = with obj
79 .x = 1
80-- a is obj
81
82b = with obj
83 break .x
84-- b is .x, not obj
85```
86
87</YueDisplay>
88
89Unlike `for` / `while` / `repeat` / `do`, `with` only supports one break value.
90
47Or… 91Or…
48 92
49```yuescript 93```yuescript
diff --git a/doc/docs/id-id/doc/advanced/do.md b/doc/docs/id-id/doc/advanced/do.md
index ac75531..52ef5dc 100644
--- a/doc/docs/id-id/doc/advanced/do.md
+++ b/doc/docs/id-id/doc/advanced/do.md
@@ -20,7 +20,27 @@ print var -- nil di sini
20 20
21</YueDisplay> 21</YueDisplay>
22 22
23`do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. 23`do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. Ekspresi `do` mendukung penggunaan `break` untuk memutus alur eksekusi dan mengembalikan banyak nilai lebih awal.
24
25```yuescript
26status, value = do
27 n = 12
28 if n > 10
29 break "large", n
30 break "small", n
31```
32
33<YueDisplay>
34
35```yue
36status, value = do
37 n = 12
38 if n > 10
39 break "large", n
40 break "small", n
41```
42
43</YueDisplay>
24 44
25```yuescript 45```yuescript
26counter = do 46counter = do
diff --git a/doc/docs/id-id/doc/control-flow/for-loop.md b/doc/docs/id-id/doc/control-flow/for-loop.md
index 65386f7..3835cce 100644
--- a/doc/docs/id-id/doc/control-flow/for-loop.md
+++ b/doc/docs/id-id/doc/control-flow/for-loop.md
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
86 86
87</YueDisplay> 87</YueDisplay>
88 88
89Selain itu, loop for mendukung break dengan nilai kembalian, sehingga loop itu sendiri bisa dipakai sebagai ekspresi yang keluar lebih awal dengan hasil bermakna. 89Selain itu, loop for mendukung break dengan nilai kembalian, sehingga loop itu sendiri bisa dipakai sebagai ekspresi yang keluar lebih awal dengan hasil bermakna. Ekspresi `for` mendukung `break` dengan banyak nilai.
90 90
91Contohnya, untuk menemukan angka pertama yang lebih besar dari 10: 91Contohnya, untuk menemukan angka pertama yang lebih besar dari 10:
92 92
@@ -106,6 +106,20 @@ first_large = for n in *numbers
106 106
107Sintaks break-dengan-nilai ini memungkinkan pola pencarian atau keluar-lebih-awal yang ringkas langsung di dalam ekspresi loop. 107Sintaks break-dengan-nilai ini memungkinkan pola pencarian atau keluar-lebih-awal yang ringkas langsung di dalam ekspresi loop.
108 108
109```yuescript
110key, score = for k, v in pairs data
111 break k, v * 10 if k == "target"
112```
113
114<YueDisplay>
115
116```yue
117key, score = for k, v in pairs data
118 break k, v * 10 if k == "target"
119```
120
121</YueDisplay>
122
109Anda juga bisa memfilter nilai dengan menggabungkan ekspresi for dengan pernyataan continue. 123Anda juga bisa memfilter nilai dengan menggabungkan ekspresi for dengan pernyataan continue.
110 124
111Loop for di akhir badan fungsi tidak diakumulasikan menjadi tabel untuk nilai kembalian (sebaliknya fungsi akan mengembalikan nil). Gunakan pernyataan return eksplisit, atau ubah loop menjadi list comprehension. 125Loop for di akhir badan fungsi tidak diakumulasikan menjadi tabel untuk nilai kembalian (sebaliknya fungsi akan mengembalikan nil). Gunakan pernyataan return eksplisit, atau ubah loop menjadi list comprehension.
diff --git a/doc/docs/id-id/doc/control-flow/while-loop.md b/doc/docs/id-id/doc/control-flow/while-loop.md
index 3e302cc..0c3a28d 100644
--- a/doc/docs/id-id/doc/control-flow/while-loop.md
+++ b/doc/docs/id-id/doc/control-flow/while-loop.md
@@ -45,7 +45,25 @@ until running == false do my_function!
45 45
46</YueDisplay> 46</YueDisplay>
47 47
48Seperti loop for, loop while juga bisa digunakan sebagai ekspresi. Selain itu, agar sebuah fungsi mengembalikan nilai akumulasi dari loop while, pernyataannya harus di-return secara eksplisit. 48Seperti loop for, loop while juga bisa digunakan sebagai ekspresi. Ekspresi `while` dan `until` mendukung `break` dengan banyak nilai.
49
50```yuescript
51value, doubled = while true
52 n = get_next!
53 break n, n * 2 if n > 10
54```
55
56<YueDisplay>
57
58```yue
59value, doubled = while true
60 n = get_next!
61 break n, n * 2 if n > 10
62```
63
64</YueDisplay>
65
66Selain itu, agar sebuah fungsi mengembalikan nilai akumulasi dari loop while, pernyataannya harus di-return secara eksplisit.
49 67
50## Repeat Loop 68## Repeat Loop
51 69
@@ -70,3 +88,25 @@ until i == 0
70``` 88```
71 89
72</YueDisplay> 90</YueDisplay>
91
92Ekspresi `repeat` juga mendukung `break` dengan banyak nilai:
93
94```yuescript
95i = 1
96value, scaled = repeat
97 break i, i * 100 if i > 3
98 i += 1
99until false
100```
101
102<YueDisplay>
103
104```yue
105i = 1
106value, scaled = repeat
107 break i, i * 100 if i > 3
108 i += 1
109until false
110```
111
112</YueDisplay>
diff --git a/doc/docs/id-id/doc/advanced/module.md b/doc/docs/id-id/doc/language-basics/module.md
index 103e3f6..103e3f6 100644
--- a/doc/docs/id-id/doc/advanced/module.md
+++ b/doc/docs/id-id/doc/language-basics/module.md
diff --git a/doc/docs/id-id/doc/objects/with-statement.md b/doc/docs/id-id/doc/objects/with-statement.md
index 96a3efd..b3dd520 100644
--- a/doc/docs/id-id/doc/objects/with-statement.md
+++ b/doc/docs/id-id/doc/objects/with-statement.md
@@ -44,6 +44,50 @@ file = with File "favorite_foods.txt"
44 44
45</YueDisplay> 45</YueDisplay>
46 46
47Ekspresi `with` mendukung `break` dengan satu nilai:
48
49```yuescript
50result = with obj
51 break .value
52```
53
54<YueDisplay>
55
56```yue
57result = with obj
58 break .value
59```
60
61</YueDisplay>
62
63Setelah `break value` digunakan di dalam `with`, ekspresi `with` tidak lagi mengembalikan objek targetnya, melainkan mengembalikan nilai dari `break`.
64
65```yuescript
66a = with obj
67 .x = 1
68-- a adalah obj
69
70b = with obj
71 break .x
72-- b adalah .x, bukan obj
73```
74
75<YueDisplay>
76
77```yue
78a = with obj
79 .x = 1
80-- a adalah obj
81
82b = with obj
83 break .x
84-- b adalah .x, bukan obj
85```
86
87</YueDisplay>
88
89Berbeda dari `for` / `while` / `repeat` / `do`, `with` hanya mendukung satu nilai `break`.
90
47Atau… 91Atau…
48 92
49```yuescript 93```yuescript
diff --git a/doc/docs/pt-br/doc/advanced/do.md b/doc/docs/pt-br/doc/advanced/do.md
index 503c551..aaf2c69 100644
--- a/doc/docs/pt-br/doc/advanced/do.md
+++ b/doc/docs/pt-br/doc/advanced/do.md
@@ -20,7 +20,27 @@ print var -- nil aqui
20 20
21</YueDisplay> 21</YueDisplay>
22 22
23O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. 23O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. Expressões `do` suportam usar `break` para interromper o fluxo de execução e retornar múltiplos valores antecipadamente.
24
25```yuescript
26status, value = do
27 n = 12
28 if n > 10
29 break "large", n
30 break "small", n
31```
32
33<YueDisplay>
34
35```yue
36status, value = do
37 n = 12
38 if n > 10
39 break "large", n
40 break "small", n
41```
42
43</YueDisplay>
24 44
25```yuescript 45```yuescript
26counter = do 46counter = do
diff --git a/doc/docs/pt-br/doc/control-flow/for-loop.md b/doc/docs/pt-br/doc/control-flow/for-loop.md
index 4c99e6d..de5f9c2 100644
--- a/doc/docs/pt-br/doc/control-flow/for-loop.md
+++ b/doc/docs/pt-br/doc/control-flow/for-loop.md
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
86 86
87</YueDisplay> 87</YueDisplay>
88 88
89Além disso, os loops for suportam break com valor de retorno, permitindo que o próprio loop seja usado como expressão que sai antecipadamente com um resultado significativo. 89Além disso, os loops for suportam break com valores de retorno, permitindo que o próprio loop seja usado como expressão que sai antecipadamente com um resultado significativo. Expressões `for` suportam `break` com múltiplos valores.
90 90
91Por exemplo, para encontrar o primeiro número maior que 10: 91Por exemplo, para encontrar o primeiro número maior que 10:
92 92
@@ -106,6 +106,20 @@ first_large = for n in *numbers
106 106
107Esta sintaxe de break-com-valor permite padrões concisos e expressivos de busca ou saída antecipada diretamente em expressões de loop. 107Esta sintaxe de break-com-valor permite padrões concisos e expressivos de busca ou saída antecipada diretamente em expressões de loop.
108 108
109```yuescript
110key, score = for k, v in pairs data
111 break k, v * 10 if k == "target"
112```
113
114<YueDisplay>
115
116```yue
117key, score = for k, v in pairs data
118 break k, v * 10 if k == "target"
119```
120
121</YueDisplay>
122
109Você também pode filtrar valores combinando a expressão do loop for com a instrução continue. 123Você também pode filtrar valores combinando a expressão do loop for com a instrução continue.
110 124
111Loops for no final do corpo de uma função não são acumulados em uma tabela para valor de retorno (em vez disso, a função retornará nil). Uma instrução return explícita pode ser usada, ou o loop pode ser convertido em compreensão de lista. 125Loops for no final do corpo de uma função não são acumulados em uma tabela para valor de retorno (em vez disso, a função retornará nil). Uma instrução return explícita pode ser usada, ou o loop pode ser convertido em compreensão de lista.
diff --git a/doc/docs/pt-br/doc/control-flow/while-loop.md b/doc/docs/pt-br/doc/control-flow/while-loop.md
index 2deb5aa..38df05a 100644
--- a/doc/docs/pt-br/doc/control-flow/while-loop.md
+++ b/doc/docs/pt-br/doc/control-flow/while-loop.md
@@ -45,7 +45,25 @@ until running == false do my_function!
45 45
46</YueDisplay> 46</YueDisplay>
47 47
48Como os loops for, o loop while também pode ser usado como expressão. Além disso, para uma função retornar o valor acumulado de um loop while, a instrução deve ser explicitamente retornada. 48Como os loops for, o loop while também pode ser usado como expressão. Expressões `while` e `until` suportam `break` com múltiplos valores.
49
50```yuescript
51value, doubled = while true
52 n = get_next!
53 break n, n * 2 if n > 10
54```
55
56<YueDisplay>
57
58```yue
59value, doubled = while true
60 n = get_next!
61 break n, n * 2 if n > 10
62```
63
64</YueDisplay>
65
66Além disso, para uma função retornar o valor acumulado de um loop while, a instrução deve ser explicitamente retornada.
49 67
50## Loop Repeat 68## Loop Repeat
51 69
@@ -70,3 +88,25 @@ until i == 0
70``` 88```
71 89
72</YueDisplay> 90</YueDisplay>
91
92Expressões `repeat` também suportam `break` com múltiplos valores:
93
94```yuescript
95i = 1
96value, scaled = repeat
97 break i, i * 100 if i > 3
98 i += 1
99until false
100```
101
102<YueDisplay>
103
104```yue
105i = 1
106value, scaled = repeat
107 break i, i * 100 if i > 3
108 i += 1
109until false
110```
111
112</YueDisplay>
diff --git a/doc/docs/pt-br/doc/advanced/module.md b/doc/docs/pt-br/doc/language-basics/module.md
index ed13107..ed13107 100644
--- a/doc/docs/pt-br/doc/advanced/module.md
+++ b/doc/docs/pt-br/doc/language-basics/module.md
diff --git a/doc/docs/pt-br/doc/objects/with-statement.md b/doc/docs/pt-br/doc/objects/with-statement.md
index e5a56e5..38efee7 100644
--- a/doc/docs/pt-br/doc/objects/with-statement.md
+++ b/doc/docs/pt-br/doc/objects/with-statement.md
@@ -44,6 +44,50 @@ file = with File "favorite_foods.txt"
44 44
45</YueDisplay> 45</YueDisplay>
46 46
47Expressões `with` suportam `break` com um valor:
48
49```yuescript
50result = with obj
51 break .value
52```
53
54<YueDisplay>
55
56```yue
57result = with obj
58 break .value
59```
60
61</YueDisplay>
62
63Depois que `break value` é usado dentro de `with`, a expressão `with` deixa de retornar seu objeto-alvo e passa a retornar o valor de `break`.
64
65```yuescript
66a = with obj
67 .x = 1
68-- a é obj
69
70b = with obj
71 break .x
72-- b é .x, não obj
73```
74
75<YueDisplay>
76
77```yue
78a = with obj
79 .x = 1
80-- a é obj
81
82b = with obj
83 break .x
84-- b é .x, não obj
85```
86
87</YueDisplay>
88
89Diferente de `for` / `while` / `repeat` / `do`, `with` suporta apenas um valor de `break`.
90
47Ou… 91Ou…
48 92
49```yuescript 93```yuescript
diff --git a/doc/docs/zh/doc/advanced/do.md b/doc/docs/zh/doc/advanced/do.md
index a2d5d19..b3f61af 100644
--- a/doc/docs/zh/doc/advanced/do.md
+++ b/doc/docs/zh/doc/advanced/do.md
@@ -20,7 +20,27 @@ print var -- 这里是nil
20 20
21</YueDisplay> 21</YueDisplay>
22 22
23&emsp;&emsp;月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。 23&emsp;&emsp;月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。`do` 表达式支持通过 `break` 打断执行流并提前返回多个值。
24
25```yuescript
26status, value = do
27 n = 12
28 if n > 10
29 break "large", n
30 break "small", n
31```
32
33<YueDisplay>
34
35```yue
36status, value = do
37 n = 12
38 if n > 10
39 break "large", n
40 break "small", n
41```
42
43</YueDisplay>
24 44
25```yuescript 45```yuescript
26counter = do 46counter = do
diff --git a/doc/docs/zh/doc/control-flow/for-loop.md b/doc/docs/zh/doc/control-flow/for-loop.md
index 52180b7..97e66f9 100644
--- a/doc/docs/zh/doc/control-flow/for-loop.md
+++ b/doc/docs/zh/doc/control-flow/for-loop.md
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
86 86
87</YueDisplay> 87</YueDisplay>
88 88
89&emsp;&emsp;此外,for 循环还支持带返回值的 break 语句,这样循环本身就可以作为一个表达式,在满足条件时提前退出并返回有意义的结果。 89&emsp;&emsp;此外,for 循环还支持带返回值的 break 语句,这样循环本身就可以作为一个表达式,在满足条件时提前退出并返回有意义的结果。for 循环表达式支持 `break` 返回多个值。
90 90
91&emsp;&emsp;例如,查找第一个大于 10 的数字: 91&emsp;&emsp;例如,查找第一个大于 10 的数字:
92 92
@@ -104,6 +104,20 @@ first_large = for n in *numbers
104 104
105</YueDisplay> 105</YueDisplay>
106 106
107```yuescript
108key, score = for k, v in pairs data
109 break k, v * 10 if k == "target"
110```
111
112<YueDisplay>
113
114```yue
115key, score = for k, v in pairs data
116 break k, v * 10 if k == "target"
117```
118
119</YueDisplay>
120
107&emsp;&emsp;你还可以结合 for 循环表达式与 continue 语句来过滤值。 121&emsp;&emsp;你还可以结合 for 循环表达式与 continue 语句来过滤值。
108 122
109&emsp;&emsp;注意出现在函数体末尾的 for 循环,不会被当作是一个表达式并将循环结果累积到一个列表中作为返回值(相反,函数将返回 nil)。如果要函数末尾的循环转换为列表表达式,可以显式地使用返回语句加 for 循环表达式。 123&emsp;&emsp;注意出现在函数体末尾的 for 循环,不会被当作是一个表达式并将循环结果累积到一个列表中作为返回值(相反,函数将返回 nil)。如果要函数末尾的循环转换为列表表达式,可以显式地使用返回语句加 for 循环表达式。
diff --git a/doc/docs/zh/doc/control-flow/while-loop.md b/doc/docs/zh/doc/control-flow/while-loop.md
index 3c624fe..0138d85 100644
--- a/doc/docs/zh/doc/control-flow/while-loop.md
+++ b/doc/docs/zh/doc/control-flow/while-loop.md
@@ -45,7 +45,25 @@ until running == false do my_function!
45 45
46</YueDisplay> 46</YueDisplay>
47 47
48&emsp;&emsp;像 for 循环的语法一样,while 循环也可以作为一个表达式使用。为了使函数返回 while 循环的累积列表值,必须明确使用返回语句返回 while 循环表达式。 48&emsp;&emsp;像 for 循环的语法一样,while 循环也可以作为一个表达式使用。while / until 循环表达式支持 `break` 返回多个值。
49
50```yuescript
51value, doubled = while true
52 n = get_next!
53 break n, n * 2 if n > 10
54```
55
56<YueDisplay>
57
58```yue
59value, doubled = while true
60 n = get_next!
61 break n, n * 2 if n > 10
62```
63
64</YueDisplay>
65
66&emsp;&emsp;为了使函数返回 while 循环的累积列表值,必须明确使用返回语句返回 while 循环表达式。
49 67
50## repeat 循环 68## repeat 循环
51 69
@@ -70,3 +88,25 @@ until i == 0
70``` 88```
71 89
72</YueDisplay> 90</YueDisplay>
91
92&emsp;&emsp;repeat 循环表达式同样支持 `break` 返回多个值:
93
94```yuescript
95i = 1
96value, scaled = repeat
97 break i, i * 100 if i > 3
98 i += 1
99until false
100```
101
102<YueDisplay>
103
104```yue
105i = 1
106value, scaled = repeat
107 break i, i * 100 if i > 3
108 i += 1
109until false
110```
111
112</YueDisplay>
diff --git a/doc/docs/zh/doc/advanced/module.md b/doc/docs/zh/doc/language-basics/module.md
index 6c90f0e..6c90f0e 100644
--- a/doc/docs/zh/doc/advanced/module.md
+++ b/doc/docs/zh/doc/language-basics/module.md
diff --git a/doc/docs/zh/doc/objects/with-statement.md b/doc/docs/zh/doc/objects/with-statement.md
index 0925050..338e2cc 100644
--- a/doc/docs/zh/doc/objects/with-statement.md
+++ b/doc/docs/zh/doc/objects/with-statement.md
@@ -44,6 +44,50 @@ file = with File "favorite_foods.txt"
44 44
45</YueDisplay> 45</YueDisplay>
46 46
47`with` 表达式支持 `break` 返回一个值:
48
49```yuescript
50result = with obj
51 break .value
52```
53
54<YueDisplay>
55
56```yue
57result = with obj
58 break .value
59```
60
61</YueDisplay>
62
63在 `with` 中使用 `break value` 后,`with` 表达式将不再返回其目标对象,而是返回 `break` 给出的值。
64
65```yuescript
66a = with obj
67 .x = 1
68-- a 是 obj
69
70b = with obj
71 break .x
72-- b 是 .x,不是 obj
73```
74
75<YueDisplay>
76
77```yue
78a = with obj
79 .x = 1
80-- a 是 obj
81
82b = with obj
83 break .x
84-- b 是 .x,不是 obj
85```
86
87</YueDisplay>
88
89与 `for` / `while` / `repeat` / `do` 不同,`with` 只支持一个 break 返回值。
90
47或者… 91或者…
48 92
49```yuescript 93```yuescript