diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-06 11:54:32 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-06 11:54:32 +0800 |
| commit | 1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d (patch) | |
| tree | 1d5c39eadcbe086d2a592ac76c8f1d288adfbe9d /doc/docs/de | |
| parent | aa3ecc7badfb39cb9167fb95c9a678257c1d9954 (diff) | |
| download | yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.tar.gz yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.tar.bz2 yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.zip | |
Updated docs.v0.32.9
Diffstat (limited to 'doc/docs/de')
32 files changed, 1180 insertions, 1194 deletions
diff --git a/doc/docs/de/doc/advanced/do.md b/doc/docs/de/doc/advanced/do.md index 4990d6f..6f81f9d 100644 --- a/doc/docs/de/doc/advanced/do.md +++ b/doc/docs/de/doc/advanced/do.md | |||
| @@ -1,25 +1,25 @@ | |||
| 1 | # Do | 1 | # Do |
| 2 | 2 | ||
| 3 | When used as a statement, do works just like it does in Lua. | 3 | Als Statement verhält sich `do` wie in Lua. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | do | 6 | do |
| 7 | var = "hello" | 7 | var = "hallo" |
| 8 | print var | 8 | print var |
| 9 | print var -- nil here | 9 | print var -- nil hier |
| 10 | ``` | 10 | ``` |
| 11 | <YueDisplay> | 11 | <YueDisplay> |
| 12 | 12 | ||
| 13 | ```yue | 13 | ```yue |
| 14 | do | 14 | do |
| 15 | var = "hello" | 15 | var = "hallo" |
| 16 | print var | 16 | print var |
| 17 | print var -- nil here | 17 | print var -- nil hier |
| 18 | ``` | 18 | ``` |
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | YueScript'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. | 22 | YueScripts **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. |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | counter = do | 25 | counter = do |
| @@ -49,7 +49,7 @@ print counter! | |||
| 49 | ```yuescript | 49 | ```yuescript |
| 50 | tbl = { | 50 | tbl = { |
| 51 | key: do | 51 | key: do |
| 52 | print "assigning key!" | 52 | print "Schlüssel wird zugewiesen!" |
| 53 | 1234 | 53 | 1234 |
| 54 | } | 54 | } |
| 55 | ``` | 55 | ``` |
| @@ -58,7 +58,7 @@ tbl = { | |||
| 58 | ```yue | 58 | ```yue |
| 59 | tbl = { | 59 | tbl = { |
| 60 | key: do | 60 | key: do |
| 61 | print "assigning key!" | 61 | print "Schlüssel wird zugewiesen!" |
| 62 | 1234 | 62 | 1234 |
| 63 | } | 63 | } |
| 64 | ``` | 64 | ``` |
diff --git a/doc/docs/de/doc/advanced/line-decorators.md b/doc/docs/de/doc/advanced/line-decorators.md index 292bc77..dd26925 100644 --- a/doc/docs/de/doc/advanced/line-decorators.md +++ b/doc/docs/de/doc/advanced/line-decorators.md | |||
| @@ -1,32 +1,32 @@ | |||
| 1 | # Line Decorators | 1 | # Line-Decorators |
| 2 | 2 | ||
| 3 | For convenience, the for loop and if statement can be applied to single statements at the end of the line: | 3 | Zur Vereinfachung können `for`-Schleifen und `if`-Anweisungen auf einzelne Anweisungen am Zeilenende angewendet werden: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "hello world" if name == "Rob" | 6 | print "Hallo Welt" if name == "Rob" |
| 7 | ``` | 7 | ``` |
| 8 | <YueDisplay> | 8 | <YueDisplay> |
| 9 | 9 | ||
| 10 | ```yue | 10 | ```yue |
| 11 | print "hello world" if name == "Rob" | 11 | print "Hallo Welt" if name == "Rob" |
| 12 | ``` | 12 | ``` |
| 13 | 13 | ||
| 14 | </YueDisplay> | 14 | </YueDisplay> |
| 15 | 15 | ||
| 16 | And with basic loops: | 16 | Und mit einfachen Schleifen: |
| 17 | 17 | ||
| 18 | ```yuescript | 18 | ```yuescript |
| 19 | print "item: ", item for item in *items | 19 | print "Element: ", item for item in *items |
| 20 | ``` | 20 | ``` |
| 21 | <YueDisplay> | 21 | <YueDisplay> |
| 22 | 22 | ||
| 23 | ```yue | 23 | ```yue |
| 24 | print "item: ", item for item in *items | 24 | print "Element: ", item for item in *items |
| 25 | ``` | 25 | ``` |
| 26 | 26 | ||
| 27 | </YueDisplay> | 27 | </YueDisplay> |
| 28 | 28 | ||
| 29 | And with while loops: | 29 | Und mit `while`-Schleifen: |
| 30 | 30 | ||
| 31 | ```yuescript | 31 | ```yuescript |
| 32 | game\update! while game\isRunning! | 32 | game\update! while game\isRunning! |
diff --git a/doc/docs/de/doc/advanced/macro.md b/doc/docs/de/doc/advanced/macro.md index 6d194c3..a3e155a 100644 --- a/doc/docs/de/doc/advanced/macro.md +++ b/doc/docs/de/doc/advanced/macro.md | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | # Macro | 1 | # Makros |
| 2 | 2 | ||
| 3 | ## Common Usage | 3 | ## Häufige Verwendung |
| 4 | 4 | ||
| 5 | Macro function is used for evaluating a string in the compile time and insert the generated codes into final compilation. | 5 | Makrofunktionen werden verwendet, um zur Compile-Zeit einen String auszuwerten und den generierten Code in die finale Kompilierung einzufügen. |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | macro PI2 = -> math.pi * 2 | 8 | macro PI2 = -> math.pi * 2 |
| 9 | area = $PI2 * 5 | 9 | area = $PI2 * 5 |
| 10 | 10 | ||
| 11 | macro HELLO = -> "'hello world'" | 11 | macro HELLO = -> "'Hallo Welt'" |
| 12 | print $HELLO | 12 | print $HELLO |
| 13 | 13 | ||
| 14 | macro config = (debugging) -> | 14 | macro config = (debugging) -> |
| @@ -27,7 +27,7 @@ $asserts item ~= nil | |||
| 27 | $config false | 27 | $config false |
| 28 | value = $assert item | 28 | value = $assert item |
| 29 | 29 | ||
| 30 | -- the passed expressions are treated as strings | 30 | -- übergebene Ausdrücke werden als Strings behandelt |
| 31 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" | 31 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" |
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| @@ -38,7 +38,7 @@ if $and f1!, f2!, f3! | |||
| 38 | macro PI2 = -> math.pi * 2 | 38 | macro PI2 = -> math.pi * 2 |
| 39 | area = $PI2 * 5 | 39 | area = $PI2 * 5 |
| 40 | 40 | ||
| 41 | macro HELLO = -> "'hello world'" | 41 | macro HELLO = -> "'Hallo Welt'" |
| 42 | print $HELLO | 42 | print $HELLO |
| 43 | 43 | ||
| 44 | macro config = (debugging) -> | 44 | macro config = (debugging) -> |
| @@ -57,7 +57,7 @@ $asserts item ~= nil | |||
| 57 | $config false | 57 | $config false |
| 58 | value = $assert item | 58 | value = $assert item |
| 59 | 59 | ||
| 60 | -- the passed expressions are treated as strings | 60 | -- übergebene Ausdrücke werden als Strings behandelt |
| 61 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" | 61 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" |
| 62 | if $and f1!, f2!, f3! | 62 | if $and f1!, f2!, f3! |
| 63 | print "OK" | 63 | print "OK" |
| @@ -65,31 +65,32 @@ if $and f1!, f2!, f3! | |||
| 65 | 65 | ||
| 66 | </YueDisplay> | 66 | </YueDisplay> |
| 67 | 67 | ||
| 68 | ## Insert Raw Codes | 68 | ## Rohcode einfügen |
| 69 | |||
| 70 | Eine Makrofunktion kann entweder einen YueScript-String oder eine Konfigurationstabelle mit Lua-Code zurückgeben. | ||
| 69 | 71 | ||
| 70 | A macro function can either return a YueScript string or a config table containing Lua codes. | ||
| 71 | ```yuescript | 72 | ```yuescript |
| 72 | macro yueFunc = (var) -> "local #{var} = ->" | 73 | macro yueFunc = (var) -> "local #{var} = ->" |
| 73 | $yueFunc funcA | 74 | $yueFunc funcA |
| 74 | funcA = -> "fail to assign to the Yue macro defined variable" | 75 | funcA = -> "Zuweisung an die vom Yue-Makro definierte Variable schlägt fehl" |
| 75 | 76 | ||
| 76 | macro luaFunc = (var) -> { | 77 | macro luaFunc = (var) -> { |
| 77 | code: "local function #{var}() end" | 78 | code: "local function #{var}() end" |
| 78 | type: "lua" | 79 | type: "lua" |
| 79 | } | 80 | } |
| 80 | $luaFunc funcB | 81 | $luaFunc funcB |
| 81 | funcB = -> "fail to assign to the Lua macro defined variable" | 82 | funcB = -> "Zuweisung an die vom Lua-Makro definierte Variable schlägt fehl" |
| 82 | 83 | ||
| 83 | macro lua = (code) -> { | 84 | macro lua = (code) -> { |
| 84 | :code | 85 | :code |
| 85 | type: "lua" | 86 | type: "lua" |
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | -- the raw string leading and ending symbols are auto trimed | 89 | -- führende und abschließende Symbole des Raw-Strings werden automatisch getrimmt |
| 89 | $lua[==[ | 90 | $lua[==[ |
| 90 | -- raw Lua codes insertion | 91 | -- Einfügen von rohem Lua-Code |
| 91 | if cond then | 92 | if cond then |
| 92 | print("output") | 93 | print("Ausgabe") |
| 93 | end | 94 | end |
| 94 | ]==] | 95 | ]==] |
| 95 | ``` | 96 | ``` |
| @@ -98,63 +99,64 @@ end | |||
| 98 | ```yue | 99 | ```yue |
| 99 | macro yueFunc = (var) -> "local #{var} = ->" | 100 | macro yueFunc = (var) -> "local #{var} = ->" |
| 100 | $yueFunc funcA | 101 | $yueFunc funcA |
| 101 | funcA = -> "fail to assign to the Yue macro defined variable" | 102 | funcA = -> "Zuweisung an die vom Yue-Makro definierte Variable schlägt fehl" |
| 102 | 103 | ||
| 103 | macro luaFunc = (var) -> { | 104 | macro luaFunc = (var) -> { |
| 104 | code: "local function #{var}() end" | 105 | code: "local function #{var}() end" |
| 105 | type: "lua" | 106 | type: "lua" |
| 106 | } | 107 | } |
| 107 | $luaFunc funcB | 108 | $luaFunc funcB |
| 108 | funcB = -> "fail to assign to the Lua macro defined variable" | 109 | funcB = -> "Zuweisung an die vom Lua-Makro definierte Variable schlägt fehl" |
| 109 | 110 | ||
| 110 | macro lua = (code) -> { | 111 | macro lua = (code) -> { |
| 111 | :code | 112 | :code |
| 112 | type: "lua" | 113 | type: "lua" |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | -- the raw string leading and ending symbols are auto trimed | 116 | -- führende und abschließende Symbole des Raw-Strings werden automatisch getrimmt |
| 116 | $lua[==[ | 117 | $lua[==[ |
| 117 | -- raw Lua codes insertion | 118 | -- Einfügen von rohem Lua-Code |
| 118 | if cond then | 119 | if cond then |
| 119 | print("output") | 120 | print("Ausgabe") |
| 120 | end | 121 | end |
| 121 | ]==] | 122 | ]==] |
| 122 | ``` | 123 | ``` |
| 123 | 124 | ||
| 124 | </YueDisplay> | 125 | </YueDisplay> |
| 125 | 126 | ||
| 126 | ## Export Macro | 127 | ## Makros exportieren |
| 128 | |||
| 129 | Makrofunktionen können aus einem Modul exportiert und in ein anderes Modul importiert werden. Exportierte Makros müssen in einer einzelnen Datei liegen, und im Export-Modul dürfen nur Makrodefinitionen, Makro-Imports und Makro-Expansionen stehen. | ||
| 127 | 130 | ||
| 128 | Macro functions can be exported from a module and get imported in another module. You have to put export macro functions in a single file to be used, and only macro definition, macro importing and macro expansion in place can be put into the macro exporting module. | ||
| 129 | ```yuescript | 131 | ```yuescript |
| 130 | -- file: utils.yue | 132 | -- Datei: utils.yue |
| 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 133 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| 132 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" | 134 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" |
| 133 | export macro foreach = (items, action) -> "for _ in *#{items} | 135 | export macro foreach = (items, action) -> "for _ in *#{items} |
| 134 | #{action}" | 136 | #{action}" |
| 135 | 137 | ||
| 136 | -- file main.yue | 138 | -- Datei main.yue |
| 137 | import "utils" as { | 139 | import "utils" as { |
| 138 | $, -- symbol to import all macros | 140 | $, -- Symbol zum Importieren aller Makros |
| 139 | $foreach: $each -- rename macro $foreach to $each | 141 | $foreach: $each -- Makro $foreach in $each umbenennen |
| 140 | } | 142 | } |
| 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 143 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 142 | ``` | 144 | ``` |
| 143 | <YueDisplay> | 145 | <YueDisplay> |
| 144 | 146 | ||
| 145 | ```yue | 147 | ```yue |
| 146 | -- file: utils.yue | 148 | -- Datei: utils.yue |
| 147 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 149 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| 148 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" | 150 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" |
| 149 | export macro foreach = (items, action) -> "for _ in *#{items} | 151 | export macro foreach = (items, action) -> "for _ in *#{items} |
| 150 | #{action}" | 152 | #{action}" |
| 151 | 153 | ||
| 152 | -- file main.yue | 154 | -- Datei main.yue |
| 153 | -- import function is not available in browser, try it in a real environment | 155 | -- Import-Funktion im Browser nicht verfügbar, in echter Umgebung testen |
| 154 | --[[ | 156 | --[[ |
| 155 | import "utils" as { | 157 | import "utils" as { |
| 156 | $, -- symbol to import all macros | 158 | $, -- Symbol zum Importieren aller Makros |
| 157 | $foreach: $each -- rename macro $foreach to $each | 159 | $foreach: $each -- Makro $foreach in $each umbenennen |
| 158 | } | 160 | } |
| 159 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 161 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 160 | ]] | 162 | ]] |
| @@ -162,32 +164,33 @@ import "utils" as { | |||
| 162 | 164 | ||
| 163 | </YueDisplay> | 165 | </YueDisplay> |
| 164 | 166 | ||
| 165 | ## Builtin Macro | 167 | ## Eingebaute Makros |
| 168 | |||
| 169 | Es gibt einige eingebaute Makros, aber du kannst sie überschreiben, indem du Makros mit denselben Namen deklarierst. | ||
| 166 | 170 | ||
| 167 | There are some builtin macros but you can override them by declaring macros with the same names. | ||
| 168 | ```yuescript | 171 | ```yuescript |
| 169 | print $FILE -- get string of current module name | 172 | print $FILE -- String des aktuellen Modulnamens |
| 170 | print $LINE -- get number 2 | 173 | print $LINE -- gibt 2 aus |
| 171 | ``` | 174 | ``` |
| 172 | <YueDisplay> | 175 | <YueDisplay> |
| 173 | 176 | ||
| 174 | ```yue | 177 | ```yue |
| 175 | print $FILE -- get string of current module name | 178 | print $FILE -- String des aktuellen Modulnamens |
| 176 | print $LINE -- get number 2 | 179 | print $LINE -- gibt 2 aus |
| 177 | ``` | 180 | ``` |
| 178 | 181 | ||
| 179 | </YueDisplay> | 182 | </YueDisplay> |
| 180 | 183 | ||
| 181 | ## Generating Macros with Macros | 184 | ## Makros mit Makros erzeugen |
| 182 | 185 | ||
| 183 | In YueScript, macro functions allow you to generate code at compile time. By nesting macro functions, you can create more complex generation patterns. This feature enables you to define a macro function that generates another macro function, allowing for more dynamic code generation. | 186 | In YueScript erlauben Makrofunktionen Codegenerierung zur Compile-Zeit. Durch das Verschachteln von Makrofunktionen kannst du komplexere Generierungsmuster erzeugen. Damit kannst du eine Makrofunktion definieren, die eine andere Makrofunktion erzeugt. |
| 184 | 187 | ||
| 185 | ```yuescript | 188 | ```yuescript |
| 186 | macro Enum = (...) -> | 189 | macro Enum = (...) -> |
| 187 | items = {...} | 190 | items = {...} |
| 188 | itemSet = {item, true for item in *items} | 191 | itemSet = {item, true for item in *items} |
| 189 | (item) -> | 192 | (item) -> |
| 190 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | 193 | error "erhalten: \"#{item}\", erwartet eines von #{table.concat items, ', '}" unless itemSet[item] |
| 191 | "\"#{item}\"" | 194 | "\"#{item}\"" |
| 192 | 195 | ||
| 193 | macro BodyType = $Enum( | 196 | macro BodyType = $Enum( |
| @@ -196,8 +199,8 @@ macro BodyType = $Enum( | |||
| 196 | Kinematic | 199 | Kinematic |
| 197 | ) | 200 | ) |
| 198 | 201 | ||
| 199 | print "Valid enum type:", $BodyType Static | 202 | print "Gültiger Enum-Typ:", $BodyType Static |
| 200 | -- print "Compilation error with enum type:", $BodyType Unknown | 203 | -- print "Kompilierungsfehler bei Enum-Typ:", $BodyType Unknown |
| 201 | ``` | 204 | ``` |
| 202 | 205 | ||
| 203 | <YueDisplay> | 206 | <YueDisplay> |
| @@ -207,7 +210,7 @@ macro Enum = (...) -> | |||
| 207 | items = {...} | 210 | items = {...} |
| 208 | itemSet = {item, true for item in *items} | 211 | itemSet = {item, true for item in *items} |
| 209 | (item) -> | 212 | (item) -> |
| 210 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | 213 | error "erhalten: \"#{item}\", erwartet eines von #{table.concat items, ', '}" unless itemSet[item] |
| 211 | "\"#{item}\"" | 214 | "\"#{item}\"" |
| 212 | 215 | ||
| 213 | macro BodyType = $Enum( | 216 | macro BodyType = $Enum( |
| @@ -216,15 +219,15 @@ macro BodyType = $Enum( | |||
| 216 | Kinematic | 219 | Kinematic |
| 217 | ) | 220 | ) |
| 218 | 221 | ||
| 219 | print "Valid enum type:", $BodyType Static | 222 | print "Gültiger Enum-Typ:", $BodyType Static |
| 220 | -- print "Compilation error with enum type:", $BodyType Unknown | 223 | -- print "Kompilierungsfehler bei Enum-Typ:", $BodyType Unknown |
| 221 | ``` | 224 | ``` |
| 222 | 225 | ||
| 223 | </YueDisplay> | 226 | </YueDisplay> |
| 224 | 227 | ||
| 225 | ## Argument Validation | 228 | ## Argument-Validierung |
| 226 | 229 | ||
| 227 | You can declare the expected AST node types in the argument list, and check whether the incoming macro arguments meet the expectations at compile time. | 230 | Du kannst erwartete AST-Knotentypen in der Argumentliste deklarieren und zur Compile-Zeit prüfen, ob die übergebenen Makroargumente den Erwartungen entsprechen. |
| 228 | 231 | ||
| 229 | ```yuescript | 232 | ```yuescript |
| 230 | macro printNumAndStr = (num `Num, str `String) -> | | 233 | macro printNumAndStr = (num `Num, str `String) -> | |
| @@ -233,7 +236,7 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 233 | #{str} | 236 | #{str} |
| 234 | ) | 237 | ) |
| 235 | 238 | ||
| 236 | $printNumAndStr 123, "hello" | 239 | $printNumAndStr 123, "hallo" |
| 237 | ``` | 240 | ``` |
| 238 | <YueDisplay> | 241 | <YueDisplay> |
| 239 | 242 | ||
| @@ -244,32 +247,32 @@ macro printNumAndStr = (num `Num, str `String) -> | | |||
| 244 | #{str} | 247 | #{str} |
| 245 | ) | 248 | ) |
| 246 | 249 | ||
| 247 | $printNumAndStr 123, "hello" | 250 | $printNumAndStr 123, "hallo" |
| 248 | ``` | 251 | ``` |
| 249 | 252 | ||
| 250 | </YueDisplay> | 253 | </YueDisplay> |
| 251 | 254 | ||
| 252 | If you need more flexible argument checking, you can use the built-in `$is_ast` macro function to manually check at the appropriate place. | 255 | Wenn du flexiblere Argumentprüfungen brauchst, kannst du das eingebaute Makro `$is_ast` verwenden, um manuell an der passenden Stelle zu prüfen. |
| 253 | 256 | ||
| 254 | ```yuescript | 257 | ```yuescript |
| 255 | macro printNumAndStr = (num, str) -> | 258 | macro printNumAndStr = (num, str) -> |
| 256 | error "expected Num as first argument" unless $is_ast Num, num | 259 | error "als erstes Argument Num erwartet" unless $is_ast Num, num |
| 257 | error "expected String as second argument" unless $is_ast String, str | 260 | error "als zweites Argument String erwartet" unless $is_ast String, str |
| 258 | "print(#{num}, #{str})" | 261 | "print(#{num}, #{str})" |
| 259 | 262 | ||
| 260 | $printNumAndStr 123, "hello" | 263 | $printNumAndStr 123, "hallo" |
| 261 | ``` | 264 | ``` |
| 262 | <YueDisplay> | 265 | <YueDisplay> |
| 263 | 266 | ||
| 264 | ```yue | 267 | ```yue |
| 265 | macro printNumAndStr = (num, str) -> | 268 | macro printNumAndStr = (num, str) -> |
| 266 | error "expected Num as first argument" unless $is_ast Num, num | 269 | error "als erstes Argument Num erwartet" unless $is_ast Num, num |
| 267 | error "expected String as second argument" unless $is_ast String, str | 270 | error "als zweites Argument String erwartet" unless $is_ast String, str |
| 268 | "print(#{num}, #{str})" | 271 | "print(#{num}, #{str})" |
| 269 | 272 | ||
| 270 | $printNumAndStr 123, "hello" | 273 | $printNumAndStr 123, "hallo" |
| 271 | ``` | 274 | ``` |
| 272 | 275 | ||
| 273 | </YueDisplay> | 276 | </YueDisplay> |
| 274 | 277 | ||
| 275 | For more details about available AST nodes, please refer to the uppercased definitions in [yue_parser.cpp](https://github.com/IppClub/YueScript/blob/main/src/yuescript/yue_parser.cpp). | 278 | Weitere Details zu verfügbaren AST-Knoten findest du in den großgeschriebenen Definitionen in `yue_parser.cpp`. |
diff --git a/doc/docs/de/doc/advanced/module.md b/doc/docs/de/doc/advanced/module.md index c955092..bdc5d86 100644 --- a/doc/docs/de/doc/advanced/module.md +++ b/doc/docs/de/doc/advanced/module.md | |||
| @@ -2,27 +2,27 @@ | |||
| 2 | 2 | ||
| 3 | ## Import | 3 | ## Import |
| 4 | 4 | ||
| 5 | The import statement is a syntax sugar for requiring a module or help extracting items from an imported module. The imported items are const by default. | 5 | Die `import`-Anweisung ist syntaktischer Zucker für `require` und hilft beim Extrahieren von Einträgen aus importierten Modulen. Importierte Elemente sind standardmäßig `const`. |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | -- used as table destructuring | 8 | -- als Tabellen-Destrukturierung |
| 9 | do | 9 | do |
| 10 | import insert, concat from table | 10 | import insert, concat from table |
| 11 | -- report error when assigning to insert, concat | 11 | -- Fehler beim Zuweisen zu insert, concat |
| 12 | import C, Ct, Cmt from require "lpeg" | 12 | import C, Ct, Cmt from require "lpeg" |
| 13 | -- shortcut for implicit requiring | 13 | -- Kurzform für implizites Require |
| 14 | import x, y, z from 'mymodule' | 14 | import x, y, z from 'mymodule' |
| 15 | -- import with Python style | 15 | -- Import im Python-Stil |
| 16 | from 'module' import a, b, c | 16 | from 'module' import a, b, c |
| 17 | 17 | ||
| 18 | -- shortcut for requring a module | 18 | -- Kurzform zum Laden eines Moduls |
| 19 | do | 19 | do |
| 20 | import 'module' | 20 | import 'module' |
| 21 | import 'module_x' | 21 | import 'module_x' |
| 22 | import "d-a-s-h-e-s" | 22 | import "d-a-s-h-e-s" |
| 23 | import "module.part" | 23 | import "module.part" |
| 24 | 24 | ||
| 25 | -- requring module with aliasing or table destructuring | 25 | -- Modul mit Alias oder Tabellen-Destrukturierung laden |
| 26 | do | 26 | do |
| 27 | import "player" as PlayerModule | 27 | import "player" as PlayerModule |
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| @@ -31,24 +31,24 @@ do | |||
| 31 | <YueDisplay> | 31 | <YueDisplay> |
| 32 | 32 | ||
| 33 | ```yue | 33 | ```yue |
| 34 | -- used as table destructuring | 34 | -- als Tabellen-Destrukturierung |
| 35 | do | 35 | do |
| 36 | import insert, concat from table | 36 | import insert, concat from table |
| 37 | -- report error when assigning to insert, concat | 37 | -- Fehler beim Zuweisen zu insert, concat |
| 38 | import C, Ct, Cmt from require "lpeg" | 38 | import C, Ct, Cmt from require "lpeg" |
| 39 | -- shortcut for implicit requiring | 39 | -- Kurzform für implizites Require |
| 40 | import x, y, z from 'mymodule' | 40 | import x, y, z from 'mymodule' |
| 41 | -- import with Python style | 41 | -- Import im Python-Stil |
| 42 | from 'module' import a, b, c | 42 | from 'module' import a, b, c |
| 43 | 43 | ||
| 44 | -- shortcut for requring a module | 44 | -- Kurzform zum Laden eines Moduls |
| 45 | do | 45 | do |
| 46 | import 'module' | 46 | import 'module' |
| 47 | import 'module_x' | 47 | import 'module_x' |
| 48 | import "d-a-s-h-e-s" | 48 | import "d-a-s-h-e-s" |
| 49 | import "module.part" | 49 | import "module.part" |
| 50 | 50 | ||
| 51 | -- requring module with aliasing or table destructuring | 51 | -- Modul mit Alias oder Tabellen-Destrukturierung laden |
| 52 | do | 52 | do |
| 53 | import "player" as PlayerModule | 53 | import "player" as PlayerModule |
| 54 | import "lpeg" as :C, :Ct, :Cmt | 54 | import "lpeg" as :C, :Ct, :Cmt |
| @@ -57,9 +57,9 @@ do | |||
| 57 | 57 | ||
| 58 | </YueDisplay> | 58 | </YueDisplay> |
| 59 | 59 | ||
| 60 | ## Import Global | 60 | ## Import von Globals |
| 61 | 61 | ||
| 62 | You can import specific globals into local variables with `import`. When importing a chain of global variable accessings, the last field will be assigned to the local variable. | 62 | Du kannst mit `import` bestimmte Globals in lokale Variablen importieren. Wenn du eine Kette von Globalzugriffen importierst, wird das letzte Feld der lokalen Variable zugewiesen. |
| 63 | 63 | ||
| 64 | ```yuescript | 64 | ```yuescript |
| 65 | do | 65 | do |
| @@ -78,21 +78,21 @@ do | |||
| 78 | 78 | ||
| 79 | </YueDisplay> | 79 | </YueDisplay> |
| 80 | 80 | ||
| 81 | ### Automatic Global Variable Import | 81 | ### Automatischer Global-Import |
| 82 | 82 | ||
| 83 | You can place `import global` at the top of a block to automatically import all names that have not been explicitly declared or assigned in the current scope as globals. These implicit imports are treated as local consts that reference the corresponding globals at the position of the statement. | 83 | Du kannst `import global` am Anfang eines Blocks platzieren, um automatisch alle Namen zu importieren, die im aktuellen Scope nicht explizit deklariert oder zugewiesen sind. Diese impliziten Importe werden als lokale `const` behandelt, die an die entsprechenden Globals zum Zeitpunkt der Anweisung gebunden sind. |
| 84 | 84 | ||
| 85 | Names that are explicitly declared as globals in the same scope will not be imported, so you can still assign to them. | 85 | Namen, die im selben Scope explizit als `global` deklariert werden, werden nicht importiert, sodass du sie weiterhin zuweisen kannst. |
| 86 | 86 | ||
| 87 | ```yuescript | 87 | ```yuescript |
| 88 | do | 88 | do |
| 89 | import global | 89 | import global |
| 90 | print "hello" | 90 | print "hallo" |
| 91 | math.random 3 | 91 | math.random 3 |
| 92 | -- print = nil -- error: imported globals are const | 92 | -- print = nil -- Fehler: importierte Globals sind const |
| 93 | 93 | ||
| 94 | do | 94 | do |
| 95 | -- explicit global variable will not be imported | 95 | -- explizite globale Variable wird nicht importiert |
| 96 | import global | 96 | import global |
| 97 | global FLAG | 97 | global FLAG |
| 98 | print FLAG | 98 | print FLAG |
| @@ -103,12 +103,12 @@ do | |||
| 103 | ```yue | 103 | ```yue |
| 104 | do | 104 | do |
| 105 | import global | 105 | import global |
| 106 | print "hello" | 106 | print "hallo" |
| 107 | math.random 3 | 107 | math.random 3 |
| 108 | -- print = nil -- error: imported globals are const | 108 | -- print = nil -- Fehler: importierte Globals sind const |
| 109 | 109 | ||
| 110 | do | 110 | do |
| 111 | -- explicit global variable will not be imported | 111 | -- explizite globale Variable wird nicht importiert |
| 112 | import global | 112 | import global |
| 113 | global FLAG | 113 | global FLAG |
| 114 | print FLAG | 114 | print FLAG |
| @@ -119,15 +119,15 @@ do | |||
| 119 | 119 | ||
| 120 | ## Export | 120 | ## Export |
| 121 | 121 | ||
| 122 | The export statement offers a concise way to define modules. | 122 | Die `export`-Anweisung bietet eine knappe Möglichkeit, Module zu definieren. |
| 123 | 123 | ||
| 124 | ### Named Export | 124 | ### Benannter Export |
| 125 | 125 | ||
| 126 | Named export will define a local variable as well as adding a field in the exported table. | 126 | Benannter Export definiert eine lokale Variable und fügt ein Feld in die exportierte Tabelle ein. |
| 127 | 127 | ||
| 128 | ```yuescript | 128 | ```yuescript |
| 129 | export a, b, c = 1, 2, 3 | 129 | export a, b, c = 1, 2, 3 |
| 130 | export cool = "cat" | 130 | export cool = "Katze" |
| 131 | 131 | ||
| 132 | export What = if this | 132 | export What = if this |
| 133 | "abc" | 133 | "abc" |
| @@ -144,7 +144,7 @@ export class Something | |||
| 144 | 144 | ||
| 145 | ```yue | 145 | ```yue |
| 146 | export a, b, c = 1, 2, 3 | 146 | export a, b, c = 1, 2, 3 |
| 147 | export cool = "cat" | 147 | export cool = "Katze" |
| 148 | 148 | ||
| 149 | export What = if this | 149 | export What = if this |
| 150 | "abc" | 150 | "abc" |
| @@ -160,7 +160,7 @@ export class Something | |||
| 160 | 160 | ||
| 161 | </YueDisplay> | 161 | </YueDisplay> |
| 162 | 162 | ||
| 163 | Doing named export with destructuring. | 163 | Benannter Export mit Destructuring. |
| 164 | 164 | ||
| 165 | ```yuescript | 165 | ```yuescript |
| 166 | export :loadstring, to_lua: tolua = yue | 166 | export :loadstring, to_lua: tolua = yue |
| @@ -175,7 +175,7 @@ export {itemA: {:fieldA = 'default'}} = tb | |||
| 175 | 175 | ||
| 176 | </YueDisplay> | 176 | </YueDisplay> |
| 177 | 177 | ||
| 178 | Export named items from module without creating local variables. | 178 | Benannte Elemente aus dem Modul exportieren, ohne lokale Variablen zu erstellen. |
| 179 | 179 | ||
| 180 | ```yuescript | 180 | ```yuescript |
| 181 | export.itemA = tb | 181 | export.itemA = tb |
| @@ -192,9 +192,9 @@ export["a-b-c"] = 123 | |||
| 192 | 192 | ||
| 193 | </YueDisplay> | 193 | </YueDisplay> |
| 194 | 194 | ||
| 195 | ### Unnamed Export | 195 | ### Unbenannter Export |
| 196 | 196 | ||
| 197 | Unnamed export will add the target item into the array part of the exported table. | 197 | Unbenannter Export fügt das Ziel-Element in den Array-Teil der exportierten Tabelle ein. |
| 198 | 198 | ||
| 199 | ```yuescript | 199 | ```yuescript |
| 200 | d, e, f = 3, 2, 1 | 200 | d, e, f = 3, 2, 1 |
| @@ -225,20 +225,20 @@ export with tmp | |||
| 225 | 225 | ||
| 226 | </YueDisplay> | 226 | </YueDisplay> |
| 227 | 227 | ||
| 228 | ### Default Export | 228 | ### Default-Export |
| 229 | 229 | ||
| 230 | Using the **default** keyword in export statement to replace the exported table with any thing. | 230 | Mit dem Schlüsselwort **default** in einer `export`-Anweisung wird die exportierte Tabelle durch ein beliebiges Objekt ersetzt. |
| 231 | 231 | ||
| 232 | ```yuescript | 232 | ```yuescript |
| 233 | export default -> | 233 | export default -> |
| 234 | print "hello" | 234 | print "hallo" |
| 235 | 123 | 235 | 123 |
| 236 | ``` | 236 | ``` |
| 237 | <YueDisplay> | 237 | <YueDisplay> |
| 238 | 238 | ||
| 239 | ```yue | 239 | ```yue |
| 240 | export default -> | 240 | export default -> |
| 241 | print "hello" | 241 | print "hallo" |
| 242 | 123 | 242 | 123 |
| 243 | ``` | 243 | ``` |
| 244 | 244 | ||
diff --git a/doc/docs/de/doc/advanced/try.md b/doc/docs/de/doc/advanced/try.md index 23c7877..4550e92 100644 --- a/doc/docs/de/doc/advanced/try.md +++ b/doc/docs/de/doc/advanced/try.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Try | 1 | # Try |
| 2 | 2 | ||
| 3 | The syntax for Lua error handling in a common form. | 3 | Die Syntax für Fehlerbehandlung in Lua in einer gängigen Form. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | try | 6 | try |
| @@ -20,10 +20,10 @@ catch err | |||
| 20 | success, result = try func 1, 2, 3 | 20 | success, result = try func 1, 2, 3 |
| 21 | 21 | ||
| 22 | try | 22 | try |
| 23 | print "trying" | 23 | print "Versuche" |
| 24 | func 1, 2, 3 | 24 | func 1, 2, 3 |
| 25 | 25 | ||
| 26 | -- working with if assignment pattern | 26 | -- Verwendung mit if-Zuweisungsmuster |
| 27 | if success, result := try func 1, 2, 3 | 27 | if success, result := try func 1, 2, 3 |
| 28 | catch err | 28 | catch err |
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| @@ -49,10 +49,10 @@ catch err | |||
| 49 | success, result = try func 1, 2, 3 | 49 | success, result = try func 1, 2, 3 |
| 50 | 50 | ||
| 51 | try | 51 | try |
| 52 | print "trying" | 52 | print "Versuche" |
| 53 | func 1, 2, 3 | 53 | func 1, 2, 3 |
| 54 | 54 | ||
| 55 | -- working with if assignment pattern | 55 | -- Verwendung mit if-Zuweisungsmuster |
| 56 | if success, result := try func 1, 2, 3 | 56 | if success, result := try func 1, 2, 3 |
| 57 | catch err | 57 | catch err |
| 58 | print yue.traceback err | 58 | print yue.traceback err |
| @@ -63,18 +63,18 @@ catch err | |||
| 63 | 63 | ||
| 64 | ## Try? | 64 | ## Try? |
| 65 | 65 | ||
| 66 | `try?` is a simplified use for error handling syntax that omit the boolean status from the `try` statement, and it will return the result from the try block when success, return nil instead of error object otherwise. | 66 | `try?` ist eine vereinfachte Fehlerbehandlungs-Syntax, die den booleschen Status aus dem `try`-Statement weglässt. Bei Erfolg gibt sie das Ergebnis des `try`-Blocks zurück, ansonsten `nil` statt eines Fehlerobjekts. |
| 67 | 67 | ||
| 68 | ```yuescript | 68 | ```yuescript |
| 69 | a, b, c = try? func! | 69 | a, b, c = try? func! |
| 70 | 70 | ||
| 71 | -- with nil coalescing operator | 71 | -- mit Nil-Verschmelzungs-Operator |
| 72 | a = (try? func!) ?? "default" | 72 | a = (try? func!) ?? "Standardwert" |
| 73 | 73 | ||
| 74 | -- as function argument | 74 | -- als Funktionsargument |
| 75 | f try? func! | 75 | f try? func! |
| 76 | 76 | ||
| 77 | -- with catch block | 77 | -- mit catch-Block |
| 78 | f try? | 78 | f try? |
| 79 | print 123 | 79 | print 123 |
| 80 | func! | 80 | func! |
| @@ -87,13 +87,13 @@ catch e | |||
| 87 | ```yue | 87 | ```yue |
| 88 | a, b, c = try? func! | 88 | a, b, c = try? func! |
| 89 | 89 | ||
| 90 | -- with nil coalescing operator | 90 | -- mit Nil-Verschmelzungs-Operator |
| 91 | a = (try? func!) ?? "default" | 91 | a = (try? func!) ?? "Standardwert" |
| 92 | 92 | ||
| 93 | -- as function argument | 93 | -- als Funktionsargument |
| 94 | f try? func! | 94 | f try? func! |
| 95 | 95 | ||
| 96 | -- with catch block | 96 | -- mit catch-Block |
| 97 | f try? | 97 | f try? |
| 98 | print 123 | 98 | print 123 |
| 99 | func! | 99 | func! |
diff --git a/doc/docs/de/doc/assignment/assignment.md b/doc/docs/de/doc/assignment/assignment.md index 4dac6f4..b74501f 100644 --- a/doc/docs/de/doc/assignment/assignment.md +++ b/doc/docs/de/doc/assignment/assignment.md | |||
| @@ -1,25 +1,26 @@ | |||
| 1 | # Assignment | 1 | # Zuweisung |
| 2 | 2 | ||
| 3 | The variable is dynamic typed and is defined as local by default. But you can change the scope of declaration by **local** and **global** statement. | 3 | Variablen sind dynamisch typisiert und standardmäßig `local`. Du kannst den Geltungsbereich mit den Statements **local** und **global** ändern. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | hello = "world" | 6 | hello = "world" |
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- uses the existing variable | 8 | hello = 123 -- nutzt die bestehende Variable |
| 9 | ``` | 9 | ``` |
| 10 | <YueDisplay> | 10 | <YueDisplay> |
| 11 | 11 | ||
| 12 | ```yue | 12 | ```yue |
| 13 | hello = "world" | 13 | hello = "world" |
| 14 | a, b, c = 1, 2, 3 | 14 | a, b, c = 1, 2, 3 |
| 15 | hello = 123 -- uses the existing variable | 15 | hello = 123 -- nutzt die bestehende Variable |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | </YueDisplay> | 18 | </YueDisplay> |
| 19 | 19 | ||
| 20 | ## Perform Update | 20 | ## Update-Zuweisung |
| 21 | |||
| 22 | Du kannst Update-Zuweisungen mit vielen binären Operatoren durchführen. | ||
| 21 | 23 | ||
| 22 | You can perform update assignment with many binary operators. | ||
| 23 | ```yuescript | 24 | ```yuescript |
| 24 | x = 1 | 25 | x = 1 |
| 25 | x += 1 | 26 | x += 1 |
| @@ -27,7 +28,7 @@ x -= 1 | |||
| 27 | x *= 10 | 28 | x *= 10 |
| 28 | x /= 10 | 29 | x /= 10 |
| 29 | x %= 10 | 30 | x %= 10 |
| 30 | s ..= "world" -- will add a new local if local variable is not exist | 31 | s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert |
| 31 | arg or= "default value" | 32 | arg or= "default value" |
| 32 | ``` | 33 | ``` |
| 33 | <YueDisplay> | 34 | <YueDisplay> |
| @@ -39,15 +40,16 @@ x -= 1 | |||
| 39 | x *= 10 | 40 | x *= 10 |
| 40 | x /= 10 | 41 | x /= 10 |
| 41 | x %= 10 | 42 | x %= 10 |
| 42 | s ..= "world" -- will add a new local if local variable is not exist | 43 | s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert |
| 43 | arg or= "default value" | 44 | arg or= "default value" |
| 44 | ``` | 45 | ``` |
| 45 | 46 | ||
| 46 | </YueDisplay> | 47 | </YueDisplay> |
| 47 | 48 | ||
| 48 | ## Chaining Assignment | 49 | ## Verkettete Zuweisung |
| 50 | |||
| 51 | Mit verketteten Zuweisungen kannst du mehrere Variablen auf denselben Wert setzen. | ||
| 49 | 52 | ||
| 50 | You can do chaining assignment to assign multiple items to hold the same value. | ||
| 51 | ```yuescript | 53 | ```yuescript |
| 52 | a = b = c = d = e = 0 | 54 | a = b = c = d = e = 0 |
| 53 | x = y = z = f! | 55 | x = y = z = f! |
| @@ -61,7 +63,8 @@ x = y = z = f! | |||
| 61 | 63 | ||
| 62 | </YueDisplay> | 64 | </YueDisplay> |
| 63 | 65 | ||
| 64 | ## Explicit Locals | 66 | ## Explizite Locals |
| 67 | |||
| 65 | ```yuescript | 68 | ```yuescript |
| 66 | do | 69 | do |
| 67 | local a = 1 | 70 | local a = 1 |
| @@ -99,7 +102,8 @@ do | |||
| 99 | 102 | ||
| 100 | </YueDisplay> | 103 | </YueDisplay> |
| 101 | 104 | ||
| 102 | ## Explicit Globals | 105 | ## Explizite Globals |
| 106 | |||
| 103 | ```yuescript | 107 | ```yuescript |
| 104 | do | 108 | do |
| 105 | global a = 1 | 109 | global a = 1 |
diff --git a/doc/docs/de/doc/assignment/destructuring-assignment.md b/doc/docs/de/doc/assignment/destructuring-assignment.md index e7b8046..0a08e22 100644 --- a/doc/docs/de/doc/assignment/destructuring-assignment.md +++ b/doc/docs/de/doc/assignment/destructuring-assignment.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Destructuring Assignment | 1 | # Destructuring-Zuweisung |
| 2 | 2 | ||
| 3 | Destructuring assignment is a way to quickly extract values from a table by their name or position in array based tables. | 3 | Destructuring-Zuweisung ist eine Möglichkeit, schnell Werte aus einer Tabelle nach Name oder Position in array-basierten Tabellen zu extrahieren. |
| 4 | 4 | ||
| 5 | Typically when you see a table literal, {1,2,3}, it is on the right hand side of an assignment because it is a value. Destructuring assignment swaps the role of the table literal, and puts it on the left hand side of an assign statement. | 5 | Normalerweise steht ein Tabellenliteral wie `{1,2,3}` auf der rechten Seite einer Zuweisung, weil es ein Wert ist. Destructuring-Zuweisung tauscht die Rolle des Tabellenliterals und setzt es auf die linke Seite der Zuweisung. |
| 6 | 6 | ||
| 7 | This is best explained with examples. Here is how you would unpack the first two values from a table: | 7 | Am besten lässt sich das mit Beispielen erklären. So entpackst du die ersten zwei Werte einer Tabelle: |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | thing = [1, 2] | 10 | thing = [1, 2] |
| @@ -23,44 +23,44 @@ print a, b | |||
| 23 | 23 | ||
| 24 | </YueDisplay> | 24 | </YueDisplay> |
| 25 | 25 | ||
| 26 | In the destructuring table literal, the key represents the key to read from the right hand side, and the value represents the name the read value will be assigned to. | 26 | Im Destructuring-Tabellenliteral repräsentiert der Schlüssel den zu lesenden Schlüssel der rechten Seite, und der Wert ist der Name, dem der gelesene Wert zugewiesen wird. |
| 27 | 27 | ||
| 28 | ```yuescript | 28 | ```yuescript |
| 29 | obj = { | 29 | obj = { |
| 30 | hello: "world" | 30 | hello: "Welt" |
| 31 | day: "tuesday" | 31 | day: "Dienstag" |
| 32 | length: 20 | 32 | length: 20 |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | {hello: hello, day: the_day} = obj | 35 | {hello: hello, day: the_day} = obj |
| 36 | print hello, the_day | 36 | print hello, the_day |
| 37 | 37 | ||
| 38 | :day = obj -- OK to do simple destructuring without braces | 38 | :day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok |
| 39 | ``` | 39 | ``` |
| 40 | <YueDisplay> | 40 | <YueDisplay> |
| 41 | 41 | ||
| 42 | ```yue | 42 | ```yue |
| 43 | obj = { | 43 | obj = { |
| 44 | hello: "world" | 44 | hello: "Welt" |
| 45 | day: "tuesday" | 45 | day: "Dienstag" |
| 46 | length: 20 | 46 | length: 20 |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | {hello: hello, day: the_day} = obj | 49 | {hello: hello, day: the_day} = obj |
| 50 | print hello, the_day | 50 | print hello, the_day |
| 51 | 51 | ||
| 52 | :day = obj -- OK to do simple destructuring without braces | 52 | :day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok |
| 53 | ``` | 53 | ``` |
| 54 | 54 | ||
| 55 | </YueDisplay> | 55 | </YueDisplay> |
| 56 | 56 | ||
| 57 | This also works with nested data structures as well: | 57 | Das funktioniert auch mit verschachtelten Datenstrukturen: |
| 58 | 58 | ||
| 59 | ```yuescript | 59 | ```yuescript |
| 60 | obj2 = { | 60 | obj2 = { |
| 61 | numbers: [1, 2, 3, 4] | 61 | numbers: [1, 2, 3, 4] |
| 62 | properties: { | 62 | properties: { |
| 63 | color: "green" | 63 | color: "grün" |
| 64 | height: 13.5 | 64 | height: 13.5 |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| @@ -74,7 +74,7 @@ print first, second, color | |||
| 74 | obj2 = { | 74 | obj2 = { |
| 75 | numbers: [1, 2, 3, 4] | 75 | numbers: [1, 2, 3, 4] |
| 76 | properties: { | 76 | properties: { |
| 77 | color: "green" | 77 | color: "grün" |
| 78 | height: 13.5 | 78 | height: 13.5 |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| @@ -85,7 +85,7 @@ print first, second, color | |||
| 85 | 85 | ||
| 86 | </YueDisplay> | 86 | </YueDisplay> |
| 87 | 87 | ||
| 88 | If the destructuring statement is complicated, feel free to spread it out over a few lines. A slightly more complicated example: | 88 | Wenn die Destructuring-Anweisung kompliziert ist, kannst du sie gerne auf mehrere Zeilen verteilen. Ein etwas komplexeres Beispiel: |
| 89 | 89 | ||
| 90 | ```yuescript | 90 | ```yuescript |
| 91 | { | 91 | { |
| @@ -108,7 +108,7 @@ If the destructuring statement is complicated, feel free to spread it out over a | |||
| 108 | 108 | ||
| 109 | </YueDisplay> | 109 | </YueDisplay> |
| 110 | 110 | ||
| 111 | It's common to extract values from at table and assign them the local variables that have the same name as the key. In order to avoid repetition we can use the **:** prefix operator: | 111 | Es ist üblich, Werte aus einer Tabelle zu extrahieren und ihnen lokale Variablen mit demselben Namen wie der Schlüssel zuzuweisen. Um Wiederholungen zu vermeiden, kannst du den Präfix-Operator **:** verwenden: |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | {:concat, :insert} = table | 114 | {:concat, :insert} = table |
| @@ -121,7 +121,7 @@ It's common to extract values from at table and assign them the local variables | |||
| 121 | 121 | ||
| 122 | </YueDisplay> | 122 | </YueDisplay> |
| 123 | 123 | ||
| 124 | This is effectively the same as import, but we can rename fields we want to extract by mixing the syntax: | 124 | Das ist effektiv dasselbe wie `import`, aber du kannst Felder umbenennen, indem du die Syntax mischst: |
| 125 | 125 | ||
| 126 | ```yuescript | 126 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 127 | {:mix, :max, random: rand} = math |
| @@ -134,20 +134,20 @@ This is effectively the same as import, but we can rename fields we want to extr | |||
| 134 | 134 | ||
| 135 | </YueDisplay> | 135 | </YueDisplay> |
| 136 | 136 | ||
| 137 | You can write default values while doing destructuring like: | 137 | Du kannst Standardwerte beim Destructuring angeben, z. B.: |
| 138 | 138 | ||
| 139 | ```yuescript | 139 | ```yuescript |
| 140 | {:name = "nameless", :job = "jobless"} = person | 140 | {:name = "namenlos", :job = "arbeitlos"} = person |
| 141 | ``` | 141 | ``` |
| 142 | <YueDisplay> | 142 | <YueDisplay> |
| 143 | 143 | ||
| 144 | ```yue | 144 | ```yue |
| 145 | {:name = "nameless", :job = "jobless"} = person | 145 | {:name = "namenlos", :job = "arbeitlos"} = person |
| 146 | ``` | 146 | ``` |
| 147 | 147 | ||
| 148 | </YueDisplay> | 148 | </YueDisplay> |
| 149 | 149 | ||
| 150 | You can use `_` as placeholder when doing a list destructuring: | 150 | Du kannst `_` als Platzhalter verwenden, wenn du eine Listen-Destructuring-Zuweisung machst: |
| 151 | 151 | ||
| 152 | ```yuescript | 152 | ```yuescript |
| 153 | [_, two, _, four] = items | 153 | [_, two, _, four] = items |
| @@ -160,64 +160,64 @@ You can use `_` as placeholder when doing a list destructuring: | |||
| 160 | 160 | ||
| 161 | </YueDisplay> | 161 | </YueDisplay> |
| 162 | 162 | ||
| 163 | ## Range Destructuring | 163 | ## Bereichs-Destructuring |
| 164 | 164 | ||
| 165 | You can use the spread operator `...` in list destructuring to capture a range of values. This is useful when you want to extract specific elements from the beginning and end of a list while collecting the rest in between. | 165 | Du kannst den Spread-Operator `...` in Listen-Destructuring verwenden, um einen Wertebereich zu erfassen. Das ist nützlich, wenn du bestimmte Elemente am Anfang und Ende einer Liste extrahieren und den Rest dazwischen sammeln willst. |
| 166 | 166 | ||
| 167 | ```yuescript | 167 | ```yuescript |
| 168 | orders = ["first", "second", "third", "fourth", "last"] | 168 | orders = ["erster", "zweiter", "dritter", "vierter", "letzter"] |
| 169 | [first, ...bulk, last] = orders | 169 | [first, ...bulk, last] = orders |
| 170 | print first -- prints: first | 170 | print first -- gibt aus: erster |
| 171 | print bulk -- prints: {"second", "third", "fourth"} | 171 | print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} |
| 172 | print last -- prints: last | 172 | print last -- gibt aus: letzter |
| 173 | ``` | 173 | ``` |
| 174 | <YueDisplay> | 174 | <YueDisplay> |
| 175 | 175 | ||
| 176 | ```yue | 176 | ```yue |
| 177 | orders = ["first", "second", "third", "fourth", "last"] | 177 | orders = ["erster", "zweiter", "dritter", "vierter", "letzter"] |
| 178 | [first, ...bulk, last] = orders | 178 | [first, ...bulk, last] = orders |
| 179 | print first -- prints: first | 179 | print first -- gibt aus: erster |
| 180 | print bulk -- prints: {"second", "third", "fourth"} | 180 | print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} |
| 181 | print last -- prints: last | 181 | print last -- gibt aus: letzter |
| 182 | ``` | 182 | ``` |
| 183 | 183 | ||
| 184 | </YueDisplay> | 184 | </YueDisplay> |
| 185 | 185 | ||
| 186 | The spread operator can be used in different positions to capture different ranges, and you can use `_` as a placeholder for the values you don't want to capture: | 186 | Der Spread-Operator kann an unterschiedlichen Positionen verwendet werden, um unterschiedliche Bereiche zu erfassen, und du kannst `_` als Platzhalter für Werte verwenden, die du nicht erfassen willst: |
| 187 | 187 | ||
| 188 | ```yuescript | 188 | ```yuescript |
| 189 | -- Capture everything after first element | 189 | -- Alles nach dem ersten Element erfassen |
| 190 | [first, ...rest] = orders | 190 | [first, ...rest] = orders |
| 191 | 191 | ||
| 192 | -- Capture everything before last element | 192 | -- Alles vor dem letzten Element erfassen |
| 193 | [...start, last] = orders | 193 | [...start, last] = orders |
| 194 | 194 | ||
| 195 | -- Capture things except the middle elements | 195 | -- Alles außer den mittleren Elementen erfassen |
| 196 | [first, ..._, last] = orders | 196 | [first, ..._, last] = orders |
| 197 | ``` | 197 | ``` |
| 198 | <YueDisplay> | 198 | <YueDisplay> |
| 199 | 199 | ||
| 200 | ```yue | 200 | ```yue |
| 201 | -- Capture everything after first element | 201 | -- Alles nach dem ersten Element erfassen |
| 202 | [first, ...rest] = orders | 202 | [first, ...rest] = orders |
| 203 | 203 | ||
| 204 | -- Capture everything before last element | 204 | -- Alles vor dem letzten Element erfassen |
| 205 | [...start, last] = orders | 205 | [...start, last] = orders |
| 206 | 206 | ||
| 207 | -- Capture things except the middle elements | 207 | -- Alles außer den mittleren Elementen erfassen |
| 208 | [first, ..._, last] = orders | 208 | [first, ..._, last] = orders |
| 209 | ``` | 209 | ``` |
| 210 | 210 | ||
| 211 | </YueDisplay> | 211 | </YueDisplay> |
| 212 | 212 | ||
| 213 | ## Destructuring In Other Places | 213 | ## Destructuring an anderen Stellen |
| 214 | 214 | ||
| 215 | Destructuring can also show up in places where an assignment implicitly takes place. An example of this is a for loop: | 215 | Destructuring kann auch an Stellen vorkommen, an denen eine Zuweisung implizit erfolgt. Ein Beispiel ist eine `for`-Schleife: |
| 216 | 216 | ||
| 217 | ```yuescript | 217 | ```yuescript |
| 218 | tuples = [ | 218 | tuples = [ |
| 219 | ["hello", "world"] | 219 | ["hallo", "Welt"] |
| 220 | ["egg", "head"] | 220 | ["Ei", "Kopf"] |
| 221 | ] | 221 | ] |
| 222 | 222 | ||
| 223 | for [left, right] in *tuples | 223 | for [left, right] in *tuples |
| @@ -227,8 +227,8 @@ for [left, right] in *tuples | |||
| 227 | 227 | ||
| 228 | ```yue | 228 | ```yue |
| 229 | tuples = [ | 229 | tuples = [ |
| 230 | ["hello", "world"] | 230 | ["hallo", "Welt"] |
| 231 | ["egg", "head"] | 231 | ["Ei", "Kopf"] |
| 232 | ] | 232 | ] |
| 233 | 233 | ||
| 234 | for [left, right] in *tuples | 234 | for [left, right] in *tuples |
| @@ -237,4 +237,4 @@ for [left, right] in *tuples | |||
| 237 | 237 | ||
| 238 | </YueDisplay> | 238 | </YueDisplay> |
| 239 | 239 | ||
| 240 | We know each element in the array table is a two item tuple, so we can unpack it directly in the names clause of the for statement using a destructure. | 240 | Wir wissen, dass jedes Element der Array-Tabelle ein 2er-Tupel ist, daher können wir es direkt in der Namensliste der `for`-Anweisung mittels Destructuring entpacken. |
diff --git a/doc/docs/de/doc/assignment/if-assignment.md b/doc/docs/de/doc/assignment/if-assignment.md index 02984e8..884a8d2 100644 --- a/doc/docs/de/doc/assignment/if-assignment.md +++ b/doc/docs/de/doc/assignment/if-assignment.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # If Assignment | 1 | # If-Zuweisung |
| 2 | 2 | ||
| 3 | `if` and `elseif` blocks can take an assignment in place of a conditional expression. Upon evaluating the conditional, the assignment will take place and the value that was assigned to will be used as the conditional expression. The assigned variable is only in scope for the body of the conditional, meaning it is never available if the value is not truthy. And you have to use "the walrus operator" `:=` instead of `=` to do assignment. | 3 | `if`- und `elseif`-Blöcke können eine Zuweisung anstelle eines Bedingungsausdrucks enthalten. Beim Auswerten der Bedingung findet die Zuweisung statt, und der zugewiesene Wert wird als Bedingung verwendet. Die zugewiesene Variable ist nur im Geltungsbereich des Bedingungsblocks verfügbar, d. h. sie ist nicht verfügbar, wenn der Wert nicht truthy ist. Für die Zuweisung musst du den "Walrus-Operator" `:=` statt `=` verwenden. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| @@ -17,55 +17,56 @@ if user := database.find_user "moon" | |||
| 17 | 17 | ||
| 18 | ```yuescript | 18 | ```yuescript |
| 19 | if hello := os.getenv "hello" | 19 | if hello := os.getenv "hello" |
| 20 | print "You have hello", hello | 20 | print "Du hast hello", hello |
| 21 | elseif world := os.getenv "world" | 21 | elseif world := os.getenv "world" |
| 22 | print "you have world", world | 22 | print "Du hast world", world |
| 23 | else | 23 | else |
| 24 | print "nothing :(" | 24 | print "nichts :(" |
| 25 | ``` | 25 | ``` |
| 26 | <YueDisplay> | 26 | <YueDisplay> |
| 27 | 27 | ||
| 28 | ```yue | 28 | ```yue |
| 29 | if hello := os.getenv "hello" | 29 | if hello := os.getenv "hello" |
| 30 | print "You have hello", hello | 30 | print "Du hast hello", hello |
| 31 | elseif world := os.getenv "world" | 31 | elseif world := os.getenv "world" |
| 32 | print "you have world", world | 32 | print "Du hast world", world |
| 33 | else | 33 | else |
| 34 | print "nothing :(" | 34 | print "nichts :(" |
| 35 | ``` | 35 | ``` |
| 36 | 36 | ||
| 37 | </YueDisplay> | 37 | </YueDisplay> |
| 38 | 38 | ||
| 39 | If assignment with multiple return values. Only the first value is getting checked, other values are scoped. | 39 | If-Zuweisung mit mehreren Rückgabewerten. Nur der erste Wert wird geprüft, andere Werte bleiben im Scope. |
| 40 | |||
| 40 | ```yuescript | 41 | ```yuescript |
| 41 | if success, result := pcall -> "get result without problems" | 42 | if success, result := pcall -> "Ergebnis ohne Probleme erhalten" |
| 42 | print result -- variable result is scoped | 43 | print result -- Variable result ist im Scope |
| 43 | print "OK" | 44 | print "OK" |
| 44 | ``` | 45 | ``` |
| 45 | <YueDisplay> | 46 | <YueDisplay> |
| 46 | 47 | ||
| 47 | ```yue | 48 | ```yue |
| 48 | if success, result := pcall -> "get result without problems" | 49 | if success, result := pcall -> "Ergebnis ohne Probleme erhalten" |
| 49 | print result -- variable result is scoped | 50 | print result -- Variable result ist im Scope |
| 50 | print "OK" | 51 | print "OK" |
| 51 | ``` | 52 | ``` |
| 52 | 53 | ||
| 53 | </YueDisplay> | 54 | </YueDisplay> |
| 54 | 55 | ||
| 55 | ## While Assignment | 56 | ## While-Zuweisung |
| 56 | 57 | ||
| 57 | You can also use if assignment in a while loop to get the value as the loop condition. | 58 | Du kannst if-Zuweisung auch in einer while-Schleife verwenden, um den Wert als Schleifenbedingung zu nutzen. |
| 58 | 59 | ||
| 59 | ```yuescript | 60 | ```yuescript |
| 60 | while byte := stream\read_one! | 61 | while byte := stream\read_one! |
| 61 | -- do something with the byte | 62 | -- mit dem Byte etwas anfangen |
| 62 | print byte | 63 | print byte |
| 63 | ``` | 64 | ``` |
| 64 | <YueDisplay> | 65 | <YueDisplay> |
| 65 | 66 | ||
| 66 | ```yue | 67 | ```yue |
| 67 | while byte := stream\read_one! | 68 | while byte := stream\read_one! |
| 68 | -- do something with the byte | 69 | -- mit dem Byte etwas anfangen |
| 69 | print byte | 70 | print byte |
| 70 | ``` | 71 | ``` |
| 71 | 72 | ||
diff --git a/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md index fb9b740..63bf016 100644 --- a/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/de/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | # The Using Clause; Controlling Destructive Assignment | 1 | # Die Using-Klausel: Destruktive Zuweisung kontrollieren |
| 2 | 2 | ||
| 3 | While lexical scoping can be a great help in reducing the complexity of the code we write, things can get unwieldy as the code size increases. Consider the following snippet: | 3 | Lexikalisches Scoping kann die Komplexität des Codes stark reduzieren, aber mit wachsendem Codeumfang kann es unübersichtlich werden. Betrachte folgendes Beispiel: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 100 | 6 | i = 100 |
| 7 | 7 | ||
| 8 | -- many lines of code... | 8 | -- viele Zeilen Code... |
| 9 | 9 | ||
| 10 | my_func = -> | 10 | my_func = -> |
| 11 | i = 10 | 11 | i = 10 |
| @@ -15,14 +15,14 @@ my_func = -> | |||
| 15 | 15 | ||
| 16 | my_func! | 16 | my_func! |
| 17 | 17 | ||
| 18 | print i -- will print 0 | 18 | print i -- wird 0 ausgeben |
| 19 | ``` | 19 | ``` |
| 20 | <YueDisplay> | 20 | <YueDisplay> |
| 21 | 21 | ||
| 22 | ```yue | 22 | ```yue |
| 23 | i = 100 | 23 | i = 100 |
| 24 | 24 | ||
| 25 | -- many lines of code... | 25 | -- viele Zeilen Code... |
| 26 | 26 | ||
| 27 | my_func = -> | 27 | my_func = -> |
| 28 | i = 10 | 28 | i = 10 |
| @@ -32,25 +32,25 @@ my_func = -> | |||
| 32 | 32 | ||
| 33 | my_func! | 33 | my_func! |
| 34 | 34 | ||
| 35 | print i -- will print 0 | 35 | print i -- wird 0 ausgeben |
| 36 | ``` | 36 | ``` |
| 37 | 37 | ||
| 38 | </YueDisplay> | 38 | </YueDisplay> |
| 39 | 39 | ||
| 40 | In my_func, we've overwritten the value of i mistakenly. In this example it is quite obvious, but consider a large, or foreign code base where it isn't clear what names have already been declared. | 40 | In `my_func` haben wir den Wert von `i` versehentlich überschrieben. In diesem Beispiel ist es offensichtlich, aber in einer großen oder fremden Codebasis ist oft nicht klar, welche Namen bereits deklariert wurden. |
| 41 | 41 | ||
| 42 | It would be helpful to say which variables from the enclosing scope we intend on change, in order to prevent us from changing others by accident. | 42 | Es wäre hilfreich, anzugeben, welche Variablen aus dem umschließenden Scope wir verändern wollen, um versehentliche Änderungen zu vermeiden. |
| 43 | 43 | ||
| 44 | The using keyword lets us do that. using nil makes sure that no closed variables are overwritten in assignment. The using clause is placed after the argument list in a function, or in place of it if there are no arguments. | 44 | Das Schlüsselwort `using` ermöglicht das. `using nil` stellt sicher, dass keine geschlossenen Variablen bei Zuweisungen überschrieben werden. Die `using`-Klausel steht nach der Argumentliste einer Funktion oder ersetzt sie, wenn es keine Argumente gibt. |
| 45 | 45 | ||
| 46 | ```yuescript | 46 | ```yuescript |
| 47 | i = 100 | 47 | i = 100 |
| 48 | 48 | ||
| 49 | my_func = (using nil) -> | 49 | my_func = (using nil) -> |
| 50 | i = "hello" -- a new local variable is created here | 50 | i = "hello" -- hier wird eine neue lokale Variable erstellt |
| 51 | 51 | ||
| 52 | my_func! | 52 | my_func! |
| 53 | print i -- prints 100, i is unaffected | 53 | print i -- gibt 100 aus, i bleibt unverändert |
| 54 | ``` | 54 | ``` |
| 55 | <YueDisplay> | 55 | <YueDisplay> |
| 56 | 56 | ||
| @@ -58,27 +58,27 @@ print i -- prints 100, i is unaffected | |||
| 58 | i = 100 | 58 | i = 100 |
| 59 | 59 | ||
| 60 | my_func = (using nil) -> | 60 | my_func = (using nil) -> |
| 61 | i = "hello" -- a new local variable is created here | 61 | i = "hello" -- hier wird eine neue lokale Variable erstellt |
| 62 | 62 | ||
| 63 | my_func! | 63 | my_func! |
| 64 | print i -- prints 100, i is unaffected | 64 | print i -- gibt 100 aus, i bleibt unverändert |
| 65 | ``` | 65 | ``` |
| 66 | 66 | ||
| 67 | </YueDisplay> | 67 | </YueDisplay> |
| 68 | 68 | ||
| 69 | Multiple names can be separated by commas. Closure values can still be accessed, they just cant be modified: | 69 | Mehrere Namen können durch Kommas getrennt werden. Closure-Werte können weiterhin gelesen, aber nicht verändert werden: |
| 70 | 70 | ||
| 71 | ```yuescript | 71 | ```yuescript |
| 72 | tmp = 1213 | 72 | tmp = 1213 |
| 73 | i, k = 100, 50 | 73 | i, k = 100, 50 |
| 74 | 74 | ||
| 75 | my_func = (add using k, i) -> | 75 | my_func = (add using k, i) -> |
| 76 | tmp = tmp + add -- a new local tmp is created | 76 | tmp = tmp + add -- ein neues lokales tmp wird erstellt |
| 77 | i += tmp | 77 | i += tmp |
| 78 | k += tmp | 78 | k += tmp |
| 79 | 79 | ||
| 80 | my_func(22) | 80 | my_func(22) |
| 81 | print i, k -- these have been updated | 81 | print i, k -- diese wurden aktualisiert |
| 82 | ``` | 82 | ``` |
| 83 | <YueDisplay> | 83 | <YueDisplay> |
| 84 | 84 | ||
| @@ -87,12 +87,12 @@ tmp = 1213 | |||
| 87 | i, k = 100, 50 | 87 | i, k = 100, 50 |
| 88 | 88 | ||
| 89 | my_func = (add using k, i) -> | 89 | my_func = (add using k, i) -> |
| 90 | tmp = tmp + add -- a new local tmp is created | 90 | tmp = tmp + add -- ein neues lokales tmp wird erstellt |
| 91 | i += tmp | 91 | i += tmp |
| 92 | k += tmp | 92 | k += tmp |
| 93 | 93 | ||
| 94 | my_func(22) | 94 | my_func(22) |
| 95 | print i, k -- these have been updated | 95 | print i, k -- diese wurden aktualisiert |
| 96 | ``` | 96 | ``` |
| 97 | 97 | ||
| 98 | </YueDisplay> | 98 | </YueDisplay> |
diff --git a/doc/docs/de/doc/assignment/varargs-assignment.md b/doc/docs/de/doc/assignment/varargs-assignment.md index 1d66680..b211a8a 100644 --- a/doc/docs/de/doc/assignment/varargs-assignment.md +++ b/doc/docs/de/doc/assignment/varargs-assignment.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Varargs Assignment | 1 | # Varargs-Zuweisung |
| 2 | 2 | ||
| 3 | You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. | 3 | Du kannst Rückgabewerte einer Funktion dem Varargs-Symbol `...` zuweisen und dann den Inhalt auf die Lua-Weise auslesen. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | list = [1, 2, 3, 4, 5] | 6 | list = [1, 2, 3, 4, 5] |
diff --git a/doc/docs/de/doc/control-flow/conditionals.md b/doc/docs/de/doc/control-flow/conditionals.md index 5ba81cf..d20e6e3 100644 --- a/doc/docs/de/doc/control-flow/conditionals.md +++ b/doc/docs/de/doc/control-flow/conditionals.md | |||
| @@ -1,55 +1,55 @@ | |||
| 1 | # Conditionals | 1 | # Bedingungen |
| 2 | 2 | ||
| 3 | ```yuescript | 3 | ```yuescript |
| 4 | have_coins = false | 4 | have_coins = false |
| 5 | if have_coins | 5 | if have_coins |
| 6 | print "Got coins" | 6 | print "Münzen erhalten" |
| 7 | else | 7 | else |
| 8 | print "No coins" | 8 | print "Keine Münzen" |
| 9 | ``` | 9 | ``` |
| 10 | <YueDisplay> | 10 | <YueDisplay> |
| 11 | 11 | ||
| 12 | ```yue | 12 | ```yue |
| 13 | have_coins = false | 13 | have_coins = false |
| 14 | if have_coins | 14 | if have_coins |
| 15 | print "Got coins" | 15 | print "Münzen erhalten" |
| 16 | else | 16 | else |
| 17 | print "No coins" | 17 | print "Keine Münzen" |
| 18 | ``` | 18 | ``` |
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | A short syntax for single statements can also be used: | 22 | Eine Kurzsyntax für einzelne Anweisungen kann ebenfalls verwendet werden: |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | have_coins = false | 25 | have_coins = false |
| 26 | if have_coins then print "Got coins" else print "No coins" | 26 | if have_coins then print "Münzen erhalten" else print "Keine Münzen" |
| 27 | ``` | 27 | ``` |
| 28 | <YueDisplay> | 28 | <YueDisplay> |
| 29 | 29 | ||
| 30 | ```yue | 30 | ```yue |
| 31 | have_coins = false | 31 | have_coins = false |
| 32 | if have_coins then print "Got coins" else print "No coins" | 32 | if have_coins then print "Münzen erhalten" else print "Keine Münzen" |
| 33 | ``` | 33 | ``` |
| 34 | 34 | ||
| 35 | </YueDisplay> | 35 | </YueDisplay> |
| 36 | 36 | ||
| 37 | Because if statements can be used as expressions, this can also be written as: | 37 | Da `if`-Anweisungen als Ausdrücke verwendet werden können, kann man das auch so schreiben: |
| 38 | 38 | ||
| 39 | ```yuescript | 39 | ```yuescript |
| 40 | have_coins = false | 40 | have_coins = false |
| 41 | print if have_coins then "Got coins" else "No coins" | 41 | print if have_coins then "Münzen erhalten" else "Keine Münzen" |
| 42 | ``` | 42 | ``` |
| 43 | <YueDisplay> | 43 | <YueDisplay> |
| 44 | 44 | ||
| 45 | ```yue | 45 | ```yue |
| 46 | have_coins = false | 46 | have_coins = false |
| 47 | print if have_coins then "Got coins" else "No coins" | 47 | print if have_coins then "Münzen erhalten" else "Keine Münzen" |
| 48 | ``` | 48 | ``` |
| 49 | 49 | ||
| 50 | </YueDisplay> | 50 | </YueDisplay> |
| 51 | 51 | ||
| 52 | Conditionals can also be used in return statements and assignments: | 52 | Bedingungen können auch in `return`-Anweisungen und Zuweisungen verwendet werden: |
| 53 | 53 | ||
| 54 | ```yuescript | 54 | ```yuescript |
| 55 | is_tall = (name) -> | 55 | is_tall = (name) -> |
| @@ -59,11 +59,11 @@ is_tall = (name) -> | |||
| 59 | false | 59 | false |
| 60 | 60 | ||
| 61 | message = if is_tall "Rob" | 61 | message = if is_tall "Rob" |
| 62 | "I am very tall" | 62 | "Ich bin sehr groß" |
| 63 | else | 63 | else |
| 64 | "I am not so tall" | 64 | "Ich bin nicht so groß" |
| 65 | 65 | ||
| 66 | print message -- prints: I am very tall | 66 | print message -- gibt aus: Ich bin sehr groß |
| 67 | ``` | 67 | ``` |
| 68 | <YueDisplay> | 68 | <YueDisplay> |
| 69 | 69 | ||
| @@ -75,26 +75,26 @@ is_tall = (name) -> | |||
| 75 | false | 75 | false |
| 76 | 76 | ||
| 77 | message = if is_tall "Rob" | 77 | message = if is_tall "Rob" |
| 78 | "I am very tall" | 78 | "Ich bin sehr groß" |
| 79 | else | 79 | else |
| 80 | "I am not so tall" | 80 | "Ich bin nicht so groß" |
| 81 | 81 | ||
| 82 | print message -- prints: I am very tall | 82 | print message -- gibt aus: Ich bin sehr groß |
| 83 | ``` | 83 | ``` |
| 84 | 84 | ||
| 85 | </YueDisplay> | 85 | </YueDisplay> |
| 86 | 86 | ||
| 87 | The opposite of if is unless: | 87 | Das Gegenteil von `if` ist `unless`: |
| 88 | 88 | ||
| 89 | ```yuescript | 89 | ```yuescript |
| 90 | unless os.date("%A") == "Monday" | 90 | unless os.date("%A") == "Monday" |
| 91 | print "it is not Monday!" | 91 | print "Es ist nicht Montag!" |
| 92 | ``` | 92 | ``` |
| 93 | <YueDisplay> | 93 | <YueDisplay> |
| 94 | 94 | ||
| 95 | ```yue | 95 | ```yue |
| 96 | unless os.date("%A") == "Monday" | 96 | unless os.date("%A") == "Monday" |
| 97 | print "it is not Monday!" | 97 | print "Es ist nicht Montag!" |
| 98 | ``` | 98 | ``` |
| 99 | 99 | ||
| 100 | </YueDisplay> | 100 | </YueDisplay> |
| @@ -110,18 +110,18 @@ print "You're lucky!" unless math.random! > 0.1 | |||
| 110 | 110 | ||
| 111 | </YueDisplay> | 111 | </YueDisplay> |
| 112 | 112 | ||
| 113 | ## In Expression | 113 | ## In-Ausdruck |
| 114 | 114 | ||
| 115 | You can write range checking code with an `in-expression`. | 115 | Mit einem `in`-Ausdruck kannst du Bereichsprüfungen schreiben. |
| 116 | 116 | ||
| 117 | ```yuescript | 117 | ```yuescript |
| 118 | a = 5 | 118 | a = 5 |
| 119 | 119 | ||
| 120 | if a in [1, 3, 5, 7] | 120 | if a in [1, 3, 5, 7] |
| 121 | print "checking equality with discrete values" | 121 | print "Gleichheitsprüfung mit diskreten Werten" |
| 122 | 122 | ||
| 123 | if a in list | 123 | if a in list |
| 124 | print "checking if `a` is in a list" | 124 | print "Prüfen, ob `a` in einer Liste ist" |
| 125 | ``` | 125 | ``` |
| 126 | <YueDisplay> | 126 | <YueDisplay> |
| 127 | 127 | ||
| @@ -129,21 +129,10 @@ if a in list | |||
| 129 | a = 5 | 129 | a = 5 |
| 130 | 130 | ||
| 131 | if a in [1, 3, 5, 7] | 131 | if a in [1, 3, 5, 7] |
| 132 | print "checking equality with discrete values" | 132 | print "Gleichheitsprüfung mit diskreten Werten" |
| 133 | 133 | ||
| 134 | if a in list | 134 | if a in list |
| 135 | print "checking if `a` is in a list" | 135 | print "Prüfen, ob `a` in einer Liste ist" |
| 136 | ``` | ||
| 137 | |||
| 138 | </YueDisplay> | ||
| 139 | |||
| 140 | ```yuescript | ||
| 141 | print "You're lucky!" unless math.random! > 0.1 | ||
| 142 | ``` | ||
| 143 | <YueDisplay> | ||
| 144 | |||
| 145 | ```yue | ||
| 146 | print "You're lucky!" unless math.random! > 0.1 | ||
| 147 | ``` | 136 | ``` |
| 148 | 137 | ||
| 149 | </YueDisplay> | 138 | </YueDisplay> |
diff --git a/doc/docs/de/doc/control-flow/continue.md b/doc/docs/de/doc/control-flow/continue.md index b000765..a6210d4 100644 --- a/doc/docs/de/doc/control-flow/continue.md +++ b/doc/docs/de/doc/control-flow/continue.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Continue | 1 | # Continue |
| 2 | 2 | ||
| 3 | A continue statement can be used to skip the current iteration in a loop. | 3 | Eine `continue`-Anweisung überspringt die aktuelle Iteration einer Schleife. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 0 | 6 | i = 0 |
| @@ -21,7 +21,7 @@ while i < 10 | |||
| 21 | 21 | ||
| 22 | </YueDisplay> | 22 | </YueDisplay> |
| 23 | 23 | ||
| 24 | continue can also be used with loop expressions to prevent that iteration from accumulating into the result. This examples filters the array table into just even numbers: | 24 | `continue` kann auch mit Schleifenausdrücken verwendet werden, um zu verhindern, dass diese Iteration in das Ergebnis akkumuliert wird. Dieses Beispiel filtert die Array-Tabelle auf gerade Zahlen: |
| 25 | 25 | ||
| 26 | ```yuescript | 26 | ```yuescript |
| 27 | my_numbers = [1, 2, 3, 4, 5, 6] | 27 | my_numbers = [1, 2, 3, 4, 5, 6] |
diff --git a/doc/docs/de/doc/control-flow/for-loop.md b/doc/docs/de/doc/control-flow/for-loop.md index cabcde5..3bf63d4 100644 --- a/doc/docs/de/doc/control-flow/for-loop.md +++ b/doc/docs/de/doc/control-flow/for-loop.md | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | # For Loop | 1 | # For-Schleife |
| 2 | 2 | ||
| 3 | There are two for loop forms, just like in Lua. A numeric one and a generic one: | 3 | Es gibt zwei Formen der `for`-Schleife, genau wie in Lua: eine numerische und eine generische. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | for i = 10, 20 | 6 | for i = 10, 20 |
| 7 | print i | 7 | print i |
| 8 | 8 | ||
| 9 | for k = 1, 15, 2 -- an optional step provided | 9 | for k = 1, 15, 2 -- ein optionaler Schritt |
| 10 | print k | 10 | print k |
| 11 | 11 | ||
| 12 | for key, value in pairs object | 12 | for key, value in pairs object |
| @@ -18,7 +18,7 @@ for key, value in pairs object | |||
| 18 | for i = 10, 20 | 18 | for i = 10, 20 |
| 19 | print i | 19 | print i |
| 20 | 20 | ||
| 21 | for k = 1, 15, 2 -- an optional step provided | 21 | for k = 1, 15, 2 -- ein optionaler Schritt |
| 22 | print k | 22 | print k |
| 23 | 23 | ||
| 24 | for key, value in pairs object | 24 | for key, value in pairs object |
| @@ -27,7 +27,7 @@ for key, value in pairs object | |||
| 27 | 27 | ||
| 28 | </YueDisplay> | 28 | </YueDisplay> |
| 29 | 29 | ||
| 30 | The slicing and **\*** operators can be used, just like with comprehensions: | 30 | Die Slicing- und **\***-Operatoren können verwendet werden, genau wie bei Comprehensions: |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | for item in *items[2, 4] | 33 | for item in *items[2, 4] |
| @@ -42,7 +42,7 @@ for item in *items[2, 4] | |||
| 42 | 42 | ||
| 43 | </YueDisplay> | 43 | </YueDisplay> |
| 44 | 44 | ||
| 45 | A shorter syntax is also available for all variations when the body is only a single line: | 45 | Eine kürzere Syntax ist für alle Varianten verfügbar, wenn der Rumpf nur eine Zeile hat: |
| 46 | 46 | ||
| 47 | ```yuescript | 47 | ```yuescript |
| 48 | for item in *items do print item | 48 | for item in *items do print item |
| @@ -59,9 +59,9 @@ for j = 1, 10, 3 do print j | |||
| 59 | 59 | ||
| 60 | </YueDisplay> | 60 | </YueDisplay> |
| 61 | 61 | ||
| 62 | A for loop can also be used as an expression. The last statement in the body of the for loop is coerced into an expression and appended to an accumulating array table. | 62 | Eine `for`-Schleife kann auch als Ausdruck verwendet werden. Die letzte Anweisung im Schleifenrumpf wird in einen Ausdruck umgewandelt und an eine wachsende Array-Tabelle angehängt. |
| 63 | 63 | ||
| 64 | Doubling every even number: | 64 | Alle geraden Zahlen verdoppeln: |
| 65 | 65 | ||
| 66 | ```yuescript | 66 | ```yuescript |
| 67 | doubled_evens = for i = 1, 20 | 67 | doubled_evens = for i = 1, 20 |
| @@ -82,9 +82,9 @@ doubled_evens = for i = 1, 20 | |||
| 82 | 82 | ||
| 83 | </YueDisplay> | 83 | </YueDisplay> |
| 84 | 84 | ||
| 85 | In 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. | 85 | Zusä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. |
| 86 | 86 | ||
| 87 | For example, to find the first number greater than 10: | 87 | Beispiel: die erste Zahl größer als 10 finden: |
| 88 | 88 | ||
| 89 | ```yuescript | 89 | ```yuescript |
| 90 | first_large = for n in *numbers | 90 | first_large = for n in *numbers |
| @@ -99,18 +99,18 @@ first_large = for n in *numbers | |||
| 99 | 99 | ||
| 100 | </YueDisplay> | 100 | </YueDisplay> |
| 101 | 101 | ||
| 102 | This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. | 102 | Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken. |
| 103 | 103 | ||
| 104 | You can also filter values by combining the for loop expression with the continue statement. | 104 | Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst. |
| 105 | 105 | ||
| 106 | For 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. | 106 | `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. |
| 107 | 107 | ||
| 108 | ```yuescript | 108 | ```yuescript |
| 109 | func_a = -> for i = 1, 10 do print i | 109 | func_a = -> for i = 1, 10 do print i |
| 110 | func_b = -> return for i = 1, 10 do i | 110 | func_b = -> return for i = 1, 10 do i |
| 111 | 111 | ||
| 112 | print func_a! -- prints nil | 112 | print func_a! -- gibt nil aus |
| 113 | print func_b! -- prints table object | 113 | print func_b! -- gibt Tabellenobjekt aus |
| 114 | ``` | 114 | ``` |
| 115 | <YueDisplay> | 115 | <YueDisplay> |
| 116 | 116 | ||
| @@ -118,10 +118,10 @@ print func_b! -- prints table object | |||
| 118 | func_a = -> for i = 1, 10 do print i | 118 | func_a = -> for i = 1, 10 do print i |
| 119 | func_b = -> return for i = 1, 10 do i | 119 | func_b = -> return for i = 1, 10 do i |
| 120 | 120 | ||
| 121 | print func_a! -- prints nil | 121 | print func_a! -- gibt nil aus |
| 122 | print func_b! -- prints table object | 122 | print func_b! -- gibt Tabellenobjekt aus |
| 123 | ``` | 123 | ``` |
| 124 | 124 | ||
| 125 | </YueDisplay> | 125 | </YueDisplay> |
| 126 | 126 | ||
| 127 | This is done to avoid the needless creation of tables for functions that don't need to return the results of the loop. | 127 | Das verhindert die unnötige Erstellung von Tabellen in Funktionen, die die Ergebnisse der Schleife nicht zurückgeben müssen. |
diff --git a/doc/docs/de/doc/control-flow/switch.md b/doc/docs/de/doc/control-flow/switch.md index f503a80..81e08bd 100644 --- a/doc/docs/de/doc/control-flow/switch.md +++ b/doc/docs/de/doc/control-flow/switch.md | |||
| @@ -1,33 +1,33 @@ | |||
| 1 | # Switch | 1 | # Switch |
| 2 | 2 | ||
| 3 | The switch statement is shorthand for writing a series of if statements that check against the same value. Note that the value is only evaluated once. Like if statements, switches can have an else block to handle no matches. Comparison is done with the == operator. In switch statement, you can also use assignment expression to store temporary variable value. | 3 | Die `switch`-Anweisung ist eine Kurzform für eine Reihe von `if`-Anweisungen, die gegen denselben Wert prüfen. Der Wert wird nur einmal ausgewertet. Wie bei `if` kann `switch` einen `else`-Block haben, wenn keine Übereinstimmung gefunden wird. Verglichen wird mit dem Operator `==`. In einer `switch`-Anweisung kannst du auch eine Zuweisung verwenden, um den temporären Wert zu speichern. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | switch name := "Dan" | 6 | switch name := "Dan" |
| 7 | when "Robert" | 7 | when "Robert" |
| 8 | print "You are Robert" | 8 | print "Du bist Robert" |
| 9 | when "Dan", "Daniel" | 9 | when "Dan", "Daniel" |
| 10 | print "Your name, it's Dan" | 10 | print "Dein Name ist Dan" |
| 11 | else | 11 | else |
| 12 | print "I don't know about you with name #{name}" | 12 | print "Ich kenne dich nicht mit dem Namen #{name}" |
| 13 | ``` | 13 | ``` |
| 14 | <YueDisplay> | 14 | <YueDisplay> |
| 15 | 15 | ||
| 16 | ```yue | 16 | ```yue |
| 17 | switch name := "Dan" | 17 | switch name := "Dan" |
| 18 | when "Robert" | 18 | when "Robert" |
| 19 | print "You are Robert" | 19 | print "Du bist Robert" |
| 20 | when "Dan", "Daniel" | 20 | when "Dan", "Daniel" |
| 21 | print "Your name, it's Dan" | 21 | print "Dein Name ist Dan" |
| 22 | else | 22 | else |
| 23 | print "I don't know about you with name #{name}" | 23 | print "Ich kenne dich nicht mit dem Namen #{name}" |
| 24 | ``` | 24 | ``` |
| 25 | 25 | ||
| 26 | </YueDisplay> | 26 | </YueDisplay> |
| 27 | 27 | ||
| 28 | A switch when clause can match against multiple values by listing them out comma separated. | 28 | Eine `when`-Klausel kann mehrere Werte prüfen, indem sie kommasepariert aufgelistet werden. |
| 29 | 29 | ||
| 30 | Switches can be used as expressions as well, here we can assign the result of the switch to a variable: | 30 | `switch` kann auch als Ausdruck verwendet werden. Hier wird das Ergebnis der `switch`-Anweisung einer Variable zugewiesen: |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | b = 1 | 33 | b = 1 |
| @@ -37,7 +37,7 @@ next_number = switch b | |||
| 37 | when 2 | 37 | when 2 |
| 38 | 3 | 38 | 3 |
| 39 | else | 39 | else |
| 40 | error "can't count that high!" | 40 | error "so hoch kann ich nicht zählen!" |
| 41 | ``` | 41 | ``` |
| 42 | <YueDisplay> | 42 | <YueDisplay> |
| 43 | 43 | ||
| @@ -49,66 +49,66 @@ next_number = switch b | |||
| 49 | when 2 | 49 | when 2 |
| 50 | 3 | 50 | 3 |
| 51 | else | 51 | else |
| 52 | error "can't count that high!" | 52 | error "so hoch kann ich nicht zählen!" |
| 53 | ``` | 53 | ``` |
| 54 | 54 | ||
| 55 | </YueDisplay> | 55 | </YueDisplay> |
| 56 | 56 | ||
| 57 | We can use the then keyword to write a switch's when block on a single line. No extra keyword is needed to write the else block on a single line. | 57 | Du kannst das Schlüsselwort `then` verwenden, um einen `when`-Block in einer Zeile zu schreiben. Für den `else`-Block braucht es kein zusätzliches Schlüsselwort. |
| 58 | 58 | ||
| 59 | ```yuescript | 59 | ```yuescript |
| 60 | msg = switch math.random(1, 5) | 60 | msg = switch math.random(1, 5) |
| 61 | when 1 then "you are lucky" | 61 | when 1 then "Du hast Glück" |
| 62 | when 2 then "you are almost lucky" | 62 | when 2 then "Du hast fast Glück" |
| 63 | else "not so lucky" | 63 | else "nicht so viel Glück" |
| 64 | ``` | 64 | ``` |
| 65 | <YueDisplay> | 65 | <YueDisplay> |
| 66 | 66 | ||
| 67 | ```yue | 67 | ```yue |
| 68 | msg = switch math.random(1, 5) | 68 | msg = switch math.random(1, 5) |
| 69 | when 1 then "you are lucky" | 69 | when 1 then "Du hast Glück" |
| 70 | when 2 then "you are almost lucky" | 70 | when 2 then "Du hast fast Glück" |
| 71 | else "not so lucky" | 71 | else "nicht so viel Glück" |
| 72 | ``` | 72 | ``` |
| 73 | 73 | ||
| 74 | </YueDisplay> | 74 | </YueDisplay> |
| 75 | 75 | ||
| 76 | If you want to write code with one less indent when writing a switch statement, you can put the first when clause on the statement start line, and then all other clauses can be written with one less indent. | 76 | Wenn du eine Einrückung weniger möchtest, kannst du die erste `when`-Klausel in die Startzeile der Anweisung setzen und alle weiteren Klauseln mit einer Einrückung weniger schreiben. |
| 77 | 77 | ||
| 78 | ```yuescript | 78 | ```yuescript |
| 79 | switch math.random(1, 5) | 79 | switch math.random(1, 5) |
| 80 | when 1 | 80 | when 1 |
| 81 | print "you are lucky" -- two indents | 81 | print "Du hast Glück" -- zwei Einrückungen |
| 82 | else | 82 | else |
| 83 | print "not so lucky" | 83 | print "nicht so viel Glück" |
| 84 | 84 | ||
| 85 | switch math.random(1, 5) when 1 | 85 | switch math.random(1, 5) when 1 |
| 86 | print "you are lucky" -- one indent | 86 | print "Du hast Glück" -- eine Einrückung |
| 87 | else | 87 | else |
| 88 | print "not so lucky" | 88 | print "nicht so viel Glück" |
| 89 | ``` | 89 | ``` |
| 90 | <YueDisplay> | 90 | <YueDisplay> |
| 91 | 91 | ||
| 92 | ```yue | 92 | ```yue |
| 93 | switch math.random(1, 5) | 93 | switch math.random(1, 5) |
| 94 | when 1 | 94 | when 1 |
| 95 | print "you are lucky" -- two indents | 95 | print "Du hast Glück" -- zwei Einrückungen |
| 96 | else | 96 | else |
| 97 | print "not so lucky" | 97 | print "nicht so viel Glück" |
| 98 | 98 | ||
| 99 | switch math.random(1, 5) when 1 | 99 | switch math.random(1, 5) when 1 |
| 100 | print "you are lucky" -- one indent | 100 | print "Du hast Glück" -- eine Einrückung |
| 101 | else | 101 | else |
| 102 | print "not so lucky" | 102 | print "nicht so viel Glück" |
| 103 | ``` | 103 | ``` |
| 104 | 104 | ||
| 105 | </YueDisplay> | 105 | </YueDisplay> |
| 106 | 106 | ||
| 107 | It is worth noting the order of the case comparison expression. The case's expression is on the left hand side. This can be useful if the case's expression wants to overwrite how the comparison is done by defining an eq metamethod. | 107 | Beachte die Reihenfolge des Case-Vergleichsausdrucks. Der Case-Ausdruck steht auf der linken Seite. Das kann nützlich sein, wenn der Case-Ausdruck die Vergleichslogik über eine `__eq`-Metamethod selbst definiert. |
| 108 | 108 | ||
| 109 | ## Table Matching | 109 | ## Tabellen-Matching |
| 110 | 110 | ||
| 111 | You can do table matching in a switch when clause, if the table can be destructured by a specific structure and get non-nil values. | 111 | Du kannst in einer `switch`-`when`-Klausel Tabellen-Matching verwenden, wenn die Tabelle durch eine bestimmte Struktur destrukturiert werden kann und dabei nicht-`nil`-Werte liefert. |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | items = | 114 | items = |
| @@ -122,7 +122,7 @@ for item in *items | |||
| 122 | when :x, :y | 122 | when :x, :y |
| 123 | print "Vec2 #{x}, #{y}" | 123 | print "Vec2 #{x}, #{y}" |
| 124 | when :width, :height | 124 | when :width, :height |
| 125 | print "size #{width}, #{height}" | 125 | print "Größe #{width}, #{height}" |
| 126 | ``` | 126 | ``` |
| 127 | <YueDisplay> | 127 | <YueDisplay> |
| 128 | 128 | ||
| @@ -138,39 +138,39 @@ for item in *items | |||
| 138 | when :x, :y | 138 | when :x, :y |
| 139 | print "Vec2 #{x}, #{y}" | 139 | print "Vec2 #{x}, #{y}" |
| 140 | when :width, :height | 140 | when :width, :height |
| 141 | print "size #{width}, #{height}" | 141 | print "Größe #{width}, #{height}" |
| 142 | ``` | 142 | ``` |
| 143 | 143 | ||
| 144 | </YueDisplay> | 144 | </YueDisplay> |
| 145 | 145 | ||
| 146 | You can use default values to optionally destructure the table for some fields. | 146 | Du kannst Standardwerte verwenden, um bestimmte Felder optional zu destrukturieren. |
| 147 | 147 | ||
| 148 | ```yuescript | 148 | ```yuescript |
| 149 | item = {} | 149 | item = {} |
| 150 | 150 | ||
| 151 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | 151 | {pos: {:x = 50, :y = 200}} = item -- Fehler: Versuch, einen nil-Wert zu indexieren (Feld 'pos') |
| 152 | 152 | ||
| 153 | switch item | 153 | switch item |
| 154 | when {pos: {:x = 50, :y = 200}} | 154 | when {pos: {:x = 50, :y = 200}} |
| 155 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass | 155 | print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem |
| 156 | ``` | 156 | ``` |
| 157 | <YueDisplay> | 157 | <YueDisplay> |
| 158 | 158 | ||
| 159 | ```yue | 159 | ```yue |
| 160 | item = {} | 160 | item = {} |
| 161 | 161 | ||
| 162 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | 162 | {pos: {:x = 50, :y = 200}} = item -- Fehler: Versuch, einen nil-Wert zu indexieren (Feld 'pos') |
| 163 | 163 | ||
| 164 | switch item | 164 | switch item |
| 165 | when {pos: {:x = 50, :y = 200}} | 165 | when {pos: {:x = 50, :y = 200}} |
| 166 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass | 166 | print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem |
| 167 | ``` | 167 | ``` |
| 168 | 168 | ||
| 169 | </YueDisplay> | 169 | </YueDisplay> |
| 170 | 170 | ||
| 171 | You can also match against array elements, table fields, and even nested structures with array or table literals. | 171 | Du kannst auch gegen Array-Elemente, Tabellenfelder und sogar verschachtelte Strukturen mit Array- oder Tabellenliteralen matchen. |
| 172 | 172 | ||
| 173 | Match against array elements. | 173 | Matchen gegen Array-Elemente. |
| 174 | 174 | ||
| 175 | ```yuescript | 175 | ```yuescript |
| 176 | switch tb | 176 | switch tb |
| @@ -178,7 +178,7 @@ switch tb | |||
| 178 | print "1, 2, 3" | 178 | print "1, 2, 3" |
| 179 | when [1, b, 3] | 179 | when [1, b, 3] |
| 180 | print "1, #{b}, 3" | 180 | print "1, #{b}, 3" |
| 181 | when [1, 2, b = 3] -- b has a default value | 181 | when [1, 2, b = 3] -- b hat einen Standardwert |
| 182 | print "1, 2, #{b}" | 182 | print "1, 2, #{b}" |
| 183 | ``` | 183 | ``` |
| 184 | <YueDisplay> | 184 | <YueDisplay> |
| @@ -189,63 +189,63 @@ switch tb | |||
| 189 | print "1, 2, 3" | 189 | print "1, 2, 3" |
| 190 | when [1, b, 3] | 190 | when [1, b, 3] |
| 191 | print "1, #{b}, 3" | 191 | print "1, #{b}, 3" |
| 192 | when [1, 2, b = 3] -- b has a default value | 192 | when [1, 2, b = 3] -- b hat einen Standardwert |
| 193 | print "1, 2, #{b}" | 193 | print "1, 2, #{b}" |
| 194 | ``` | 194 | ``` |
| 195 | 195 | ||
| 196 | </YueDisplay> | 196 | </YueDisplay> |
| 197 | 197 | ||
| 198 | Match against table fields with destructuring. | 198 | Matchen gegen Tabellenfelder mit Destructuring. |
| 199 | 199 | ||
| 200 | ```yuescript | 200 | ```yuescript |
| 201 | switch tb | 201 | switch tb |
| 202 | when success: true, :result | 202 | when success: true, :result |
| 203 | print "success", result | 203 | print "Erfolg", result |
| 204 | when success: false | 204 | when success: false |
| 205 | print "failed", result | 205 | print "fehlgeschlagen", result |
| 206 | else | 206 | else |
| 207 | print "invalid" | 207 | print "ungültig" |
| 208 | ``` | 208 | ``` |
| 209 | <YueDisplay> | 209 | <YueDisplay> |
| 210 | 210 | ||
| 211 | ```yue | 211 | ```yue |
| 212 | switch tb | 212 | switch tb |
| 213 | when success: true, :result | 213 | when success: true, :result |
| 214 | print "success", result | 214 | print "Erfolg", result |
| 215 | when success: false | 215 | when success: false |
| 216 | print "failed", result | 216 | print "fehlgeschlagen", result |
| 217 | else | 217 | else |
| 218 | print "invalid" | 218 | print "ungültig" |
| 219 | ``` | 219 | ``` |
| 220 | 220 | ||
| 221 | </YueDisplay> | 221 | </YueDisplay> |
| 222 | 222 | ||
| 223 | Match against nested table structures. | 223 | Matchen gegen verschachtelte Tabellenstrukturen. |
| 224 | 224 | ||
| 225 | ```yuescript | 225 | ```yuescript |
| 226 | switch tb | 226 | switch tb |
| 227 | when data: {type: "success", :content} | 227 | when data: {type: "success", :content} |
| 228 | print "success", content | 228 | print "Erfolg", content |
| 229 | when data: {type: "error", :content} | 229 | when data: {type: "error", :content} |
| 230 | print "failed", content | 230 | print "fehlgeschlagen", content |
| 231 | else | 231 | else |
| 232 | print "invalid" | 232 | print "ungültig" |
| 233 | ``` | 233 | ``` |
| 234 | <YueDisplay> | 234 | <YueDisplay> |
| 235 | 235 | ||
| 236 | ```yue | 236 | ```yue |
| 237 | switch tb | 237 | switch tb |
| 238 | when data: {type: "success", :content} | 238 | when data: {type: "success", :content} |
| 239 | print "success", content | 239 | print "Erfolg", content |
| 240 | when data: {type: "error", :content} | 240 | when data: {type: "error", :content} |
| 241 | print "failed", content | 241 | print "fehlgeschlagen", content |
| 242 | else | 242 | else |
| 243 | print "invalid" | 243 | print "ungültig" |
| 244 | ``` | 244 | ``` |
| 245 | 245 | ||
| 246 | </YueDisplay> | 246 | </YueDisplay> |
| 247 | 247 | ||
| 248 | Match against array of tables. | 248 | Matchen gegen Array von Tabellen. |
| 249 | 249 | ||
| 250 | ```yuescript | 250 | ```yuescript |
| 251 | switch tb | 251 | switch tb |
| @@ -255,7 +255,7 @@ switch tb | |||
| 255 | {a: 5, b: 6} | 255 | {a: 5, b: 6} |
| 256 | fourth | 256 | fourth |
| 257 | ] | 257 | ] |
| 258 | print "matched", fourth | 258 | print "getroffen", fourth |
| 259 | ``` | 259 | ``` |
| 260 | <YueDisplay> | 260 | <YueDisplay> |
| 261 | 261 | ||
| @@ -267,20 +267,20 @@ switch tb | |||
| 267 | {a: 5, b: 6} | 267 | {a: 5, b: 6} |
| 268 | fourth | 268 | fourth |
| 269 | ] | 269 | ] |
| 270 | print "matched", fourth | 270 | print "getroffen", fourth |
| 271 | ``` | 271 | ``` |
| 272 | 272 | ||
| 273 | </YueDisplay> | 273 | </YueDisplay> |
| 274 | 274 | ||
| 275 | Match against a list and capture a range of elements. | 275 | Matchen gegen eine Liste und einen Bereich von Elementen erfassen. |
| 276 | 276 | ||
| 277 | ```yuescript | 277 | ```yuescript |
| 278 | segments = ["admin", "users", "logs", "view"] | 278 | segments = ["admin", "users", "logs", "view"] |
| 279 | switch segments | 279 | switch segments |
| 280 | when [...groups, resource, action] | 280 | when [...groups, resource, action] |
| 281 | print "Group:", groups -- prints: {"admin", "users"} | 281 | print "Gruppe:", groups -- gibt aus: {"admin", "users"} |
| 282 | print "Resource:", resource -- prints: "logs" | 282 | print "Ressource:", resource -- gibt aus: "logs" |
| 283 | print "Action:", action -- prints: "view" | 283 | print "Aktion:", action -- gibt aus: "view" |
| 284 | ``` | 284 | ``` |
| 285 | <YueDisplay> | 285 | <YueDisplay> |
| 286 | 286 | ||
| @@ -288,9 +288,9 @@ switch segments | |||
| 288 | segments = ["admin", "users", "logs", "view"] | 288 | segments = ["admin", "users", "logs", "view"] |
| 289 | switch segments | 289 | switch segments |
| 290 | when [...groups, resource, action] | 290 | when [...groups, resource, action] |
| 291 | print "Group:", groups -- prints: {"admin", "users"} | 291 | print "Gruppe:", groups -- gibt aus: {"admin", "users"} |
| 292 | print "Resource:", resource -- prints: "logs" | 292 | print "Ressource:", resource -- gibt aus: "logs" |
| 293 | print "Action:", action -- prints: "view" | 293 | print "Aktion:", action -- gibt aus: "view" |
| 294 | ``` | 294 | ``` |
| 295 | 295 | ||
| 296 | </YueDisplay> | 296 | </YueDisplay> |
diff --git a/doc/docs/de/doc/control-flow/while-loop.md b/doc/docs/de/doc/control-flow/while-loop.md index 502935e..a875bf9 100644 --- a/doc/docs/de/doc/control-flow/while-loop.md +++ b/doc/docs/de/doc/control-flow/while-loop.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # While Loop | 1 | # While-Schleife |
| 2 | 2 | ||
| 3 | The while loop also comes in four variations: | 3 | Die `while`-Schleife gibt es ebenfalls in vier Variationen: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 10 | 6 | i = 10 |
| @@ -43,11 +43,11 @@ until running == false do my_function! | |||
| 43 | 43 | ||
| 44 | </YueDisplay> | 44 | </YueDisplay> |
| 45 | 45 | ||
| 46 | Like 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. | 46 | Wie 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. |
| 47 | 47 | ||
| 48 | ## Repeat Loop | 48 | ## Repeat-Schleife |
| 49 | 49 | ||
| 50 | The repeat loop comes from Lua: | 50 | Die `repeat`-Schleife stammt aus Lua: |
| 51 | 51 | ||
| 52 | ```yuescript | 52 | ```yuescript |
| 53 | i = 10 | 53 | i = 10 |
diff --git a/doc/docs/de/doc/data-structures/comprehensions.md b/doc/docs/de/doc/data-structures/comprehensions.md index 3a92167..7e00c57 100644 --- a/doc/docs/de/doc/data-structures/comprehensions.md +++ b/doc/docs/de/doc/data-structures/comprehensions.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Comprehensions | 1 | # Comprehensions |
| 2 | 2 | ||
| 3 | Comprehensions provide a convenient syntax for constructing a new table by iterating over some existing object and applying an expression to its values. There are two kinds of comprehensions: list comprehensions and table comprehensions. They both produce Lua tables; list comprehensions accumulate values into an array-like table, and table comprehensions let you set both the key and the value on each iteration. | 3 | Comprehensions bieten eine bequeme Syntax, um eine neue Tabelle zu erzeugen, indem man über ein bestehendes Objekt iteriert und einen Ausdruck auf seine Werte anwendet. Es gibt zwei Arten: Listen-Comprehensions und Tabellen-Comprehensions. Beide erzeugen Lua-Tabellen; Listen-Comprehensions sammeln Werte in einer array-ähnlichen Tabelle, und Tabellen-Comprehensions erlauben es, Schlüssel und Wert pro Iteration zu setzen. |
| 4 | 4 | ||
| 5 | ## List Comprehensions | 5 | ## Listen-Comprehensions |
| 6 | 6 | ||
| 7 | The following creates a copy of the items table but with all the values doubled. | 7 | Das folgende Beispiel erstellt eine Kopie der `items`-Tabelle, aber mit verdoppelten Werten. |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| @@ -19,7 +19,7 @@ doubled = [item * 2 for i, item in ipairs items] | |||
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | The items included in the new table can be restricted with a when clause: | 22 | Die Elemente in der neuen Tabelle können mit einer `when`-Klausel eingeschränkt werden: |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| @@ -32,7 +32,7 @@ slice = [item for i, item in ipairs items when i > 1 and i < 3] | |||
| 32 | 32 | ||
| 33 | </YueDisplay> | 33 | </YueDisplay> |
| 34 | 34 | ||
| 35 | Because it is common to iterate over the values of a numerically indexed table, an **\*** operator is introduced. The doubled example can be rewritten as: | 35 | Da es üblich ist, über die Werte einer numerisch indizierten Tabelle zu iterieren, gibt es den **\***-Operator. Das Verdopplungsbeispiel kann so umgeschrieben werden: |
| 36 | 36 | ||
| 37 | ```yuescript | 37 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 38 | doubled = [item * 2 for item in *items] |
| @@ -45,7 +45,7 @@ doubled = [item * 2 for item in *items] | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | In list comprehensions, you can also use the spread operator `...` to flatten nested lists, achieving a flat map effect: | 48 | In Listen-Comprehensions kannst du außerdem den Spread-Operator `...` verwenden, um verschachtelte Listen zu flatten und einen Flat-Map-Effekt zu erzielen: |
| 49 | 49 | ||
| 50 | ```yuescript | 50 | ```yuescript |
| 51 | data = | 51 | data = |
| @@ -53,7 +53,7 @@ data = | |||
| 53 | b: [4, 5, 6] | 53 | b: [4, 5, 6] |
| 54 | 54 | ||
| 55 | flat = [...v for k,v in pairs data] | 55 | flat = [...v for k,v in pairs data] |
| 56 | -- flat is now [1, 2, 3, 4, 5, 6] | 56 | -- flat ist jetzt [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 57 | ``` |
| 58 | <YueDisplay> | 58 | <YueDisplay> |
| 59 | 59 | ||
| @@ -63,14 +63,14 @@ data = | |||
| 63 | b: [4, 5, 6] | 63 | b: [4, 5, 6] |
| 64 | 64 | ||
| 65 | flat = [...v for k,v in pairs data] | 65 | flat = [...v for k,v in pairs data] |
| 66 | -- flat is now [1, 2, 3, 4, 5, 6] | 66 | -- flat ist jetzt [1, 2, 3, 4, 5, 6] |
| 67 | ``` | 67 | ``` |
| 68 | 68 | ||
| 69 | </YueDisplay> | 69 | </YueDisplay> |
| 70 | 70 | ||
| 71 | The for and when clauses can be chained as much as desired. The only requirement is that a comprehension has at least one for clause. | 71 | Die `for`- und `when`-Klauseln können beliebig oft verkettet werden. Die einzige Anforderung ist, dass eine Comprehension mindestens eine `for`-Klausel enthält. |
| 72 | 72 | ||
| 73 | Using multiple for clauses is the same as using nested loops: | 73 | Mehrere `for`-Klauseln entsprechen verschachtelten Schleifen: |
| 74 | 74 | ||
| 75 | ```yuescript | 75 | ```yuescript |
| 76 | x_coords = [4, 5, 6, 7] | 76 | x_coords = [4, 5, 6, 7] |
| @@ -91,7 +91,7 @@ for y in *y_coords] | |||
| 91 | 91 | ||
| 92 | </YueDisplay> | 92 | </YueDisplay> |
| 93 | 93 | ||
| 94 | Numeric for loops can also be used in comprehensions: | 94 | Numerische `for`-Schleifen können ebenfalls in Comprehensions verwendet werden: |
| 95 | 95 | ||
| 96 | ```yuescript | 96 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 97 | evens = [i for i = 1, 100 when i % 2 == 0] |
| @@ -104,16 +104,16 @@ evens = [i for i = 1, 100 when i % 2 == 0] | |||
| 104 | 104 | ||
| 105 | </YueDisplay> | 105 | </YueDisplay> |
| 106 | 106 | ||
| 107 | ## Table Comprehensions | 107 | ## Tabellen-Comprehensions |
| 108 | 108 | ||
| 109 | The syntax for table comprehensions is very similar, only differing by using **{** and **}** and taking two values from each iteration. | 109 | Die Syntax für Tabellen-Comprehensions ist sehr ähnlich, unterscheidet sich jedoch dadurch, dass **{** und **}** verwendet werden und pro Iteration zwei Werte erzeugt werden. |
| 110 | 110 | ||
| 111 | This example makes a copy of the tablething: | 111 | Dieses Beispiel erstellt eine Kopie von `thing`: |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | thing = { | 114 | thing = { |
| 115 | color: "red" | 115 | color: "rot" |
| 116 | name: "fast" | 116 | name: "schnell" |
| 117 | width: 123 | 117 | width: 123 |
| 118 | } | 118 | } |
| 119 | 119 | ||
| @@ -123,8 +123,8 @@ thing_copy = {k, v for k, v in pairs thing} | |||
| 123 | 123 | ||
| 124 | ```yue | 124 | ```yue |
| 125 | thing = { | 125 | thing = { |
| 126 | color: "red" | 126 | color: "rot" |
| 127 | name: "fast" | 127 | name: "schnell" |
| 128 | width: 123 | 128 | width: 123 |
| 129 | } | 129 | } |
| 130 | 130 | ||
| @@ -144,7 +144,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} | |||
| 144 | 144 | ||
| 145 | </YueDisplay> | 145 | </YueDisplay> |
| 146 | 146 | ||
| 147 | The **\*** operator is also supported. Here we create a square root look up table for a few numbers. | 147 | Der **\***-Operator wird ebenfalls unterstützt. Hier erstellen wir eine Nachschlagetabelle für Quadratwurzeln einiger Zahlen. |
| 148 | 148 | ||
| 149 | ```yuescript | 149 | ```yuescript |
| 150 | numbers = [1, 2, 3, 4] | 150 | numbers = [1, 2, 3, 4] |
| @@ -159,18 +159,18 @@ sqrts = {i, math.sqrt i for i in *numbers} | |||
| 159 | 159 | ||
| 160 | </YueDisplay> | 160 | </YueDisplay> |
| 161 | 161 | ||
| 162 | The key-value tuple in a table comprehension can also come from a single expression, in which case the expression should return two values. The first is used as the key and the second is used as the value: | 162 | Das Schlüssel-Wert-Tupel in einer Tabellen-Comprehension kann auch aus einem einzelnen Ausdruck stammen; der Ausdruck muss dann zwei Werte zurückgeben. Der erste wird als Schlüssel und der zweite als Wert verwendet: |
| 163 | 163 | ||
| 164 | In this example we convert an array of pairs to a table where the first item in the pair is the key and the second is the value. | 164 | In diesem Beispiel konvertieren wir ein Array von Paaren in eine Tabelle, wobei das erste Element des Paars der Schlüssel und das zweite der Wert ist. |
| 165 | 165 | ||
| 166 | ```yuescript | 166 | ```yuescript |
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 167 | tuples = [ ["hallo", "Welt"], ["foo", "bar"]] |
| 168 | tbl = {unpack tuple for tuple in *tuples} | 168 | tbl = {unpack tuple for tuple in *tuples} |
| 169 | ``` | 169 | ``` |
| 170 | <YueDisplay> | 170 | <YueDisplay> |
| 171 | 171 | ||
| 172 | ```yue | 172 | ```yue |
| 173 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 173 | tuples = [ ["hallo", "Welt"], ["foo", "bar"]] |
| 174 | tbl = {unpack tuple for tuple in *tuples} | 174 | tbl = {unpack tuple for tuple in *tuples} |
| 175 | ``` | 175 | ``` |
| 176 | 176 | ||
| @@ -178,9 +178,9 @@ tbl = {unpack tuple for tuple in *tuples} | |||
| 178 | 178 | ||
| 179 | ## Slicing | 179 | ## Slicing |
| 180 | 180 | ||
| 181 | A special syntax is provided to restrict the items that are iterated over when using the **\*** operator. This is equivalent to setting the iteration bounds and a step size in a for loop. | 181 | Eine spezielle Syntax erlaubt es, die iterierten Elemente bei Verwendung des **\***-Operators einzuschränken. Das ist äquivalent zum Setzen von Iterationsgrenzen und Schrittweite in einer `for`-Schleife. |
| 182 | 182 | ||
| 183 | Here we can set the minimum and maximum bounds, taking all items with indexes between 1 and 5 inclusive: | 183 | Hier setzen wir die minimalen und maximalen Grenzen und nehmen alle Elemente mit Indizes zwischen 1 und 5 (inklusive): |
| 184 | 184 | ||
| 185 | ```yuescript | 185 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 186 | slice = [item for item in *items[1, 5]] |
| @@ -193,7 +193,7 @@ slice = [item for item in *items[1, 5]] | |||
| 193 | 193 | ||
| 194 | </YueDisplay> | 194 | </YueDisplay> |
| 195 | 195 | ||
| 196 | Any of the slice arguments can be left off to use a sensible default. In this example, if the max index is left off it defaults to the length of the table. This will take everything but the first element: | 196 | Jedes der Slice-Argumente kann weggelassen werden, um einen sinnvollen Standard zu verwenden. Wenn der maximale Index weggelassen wird, entspricht er der Länge der Tabelle. Dieses Beispiel nimmt alles außer dem ersten Element: |
| 197 | 197 | ||
| 198 | ```yuescript | 198 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 199 | slice = [item for item in *items[2,]] |
| @@ -206,7 +206,7 @@ slice = [item for item in *items[2,]] | |||
| 206 | 206 | ||
| 207 | </YueDisplay> | 207 | </YueDisplay> |
| 208 | 208 | ||
| 209 | If the minimum bound is left out, it defaults to 1. Here we only provide a step size and leave the other bounds blank. This takes all odd indexed items: (1, 3, 5, …) | 209 | Wenn die Mindestgrenze weggelassen wird, ist sie standardmäßig 1. Hier geben wir nur die Schrittweite an und lassen die anderen Grenzen leer. Das nimmt alle ungerad indizierten Elemente (1, 3, 5, …): |
| 210 | 210 | ||
| 211 | ```yuescript | 211 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 212 | slice = [item for item in *items[,,2]] |
| @@ -219,22 +219,22 @@ slice = [item for item in *items[,,2]] | |||
| 219 | 219 | ||
| 220 | </YueDisplay> | 220 | </YueDisplay> |
| 221 | 221 | ||
| 222 | Both the minimum and maximum bounds can be negative, which means that the bounds are counted from the end of the table. | 222 | Sowohl die Mindest- als auch die Maximalgrenze können negativ sein; dann werden die Grenzen vom Ende der Tabelle gezählt. |
| 223 | 223 | ||
| 224 | ```yuescript | 224 | ```yuescript |
| 225 | -- take the last 4 items | 225 | -- die letzten 4 Elemente nehmen |
| 226 | slice = [item for item in *items[-4,-1]] | 226 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 227 | ``` |
| 228 | <YueDisplay> | 228 | <YueDisplay> |
| 229 | 229 | ||
| 230 | ```yue | 230 | ```yue |
| 231 | -- take the last 4 items | 231 | -- die letzten 4 Elemente nehmen |
| 232 | slice = [item for item in *items[-4,-1]] | 232 | slice = [item for item in *items[-4,-1]] |
| 233 | ``` | 233 | ``` |
| 234 | 234 | ||
| 235 | </YueDisplay> | 235 | </YueDisplay> |
| 236 | 236 | ||
| 237 | The step size can also be negative, which means that the items are taken in reverse order. | 237 | Die Schrittweite kann ebenfalls negativ sein, wodurch die Elemente in umgekehrter Reihenfolge genommen werden. |
| 238 | 238 | ||
| 239 | ```yuescript | 239 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 240 | reverse_slice = [item for item in *items[-1,1,-1]] |
| @@ -247,24 +247,24 @@ reverse_slice = [item for item in *items[-1,1,-1]] | |||
| 247 | 247 | ||
| 248 | </YueDisplay> | 248 | </YueDisplay> |
| 249 | 249 | ||
| 250 | ### Slicing Expression | 250 | ### Slicing-Ausdruck |
| 251 | 251 | ||
| 252 | Slicing can also be used as an expression. This is useful for getting a sub-list of a table. | 252 | Slicing kann auch als Ausdruck verwendet werden. Das ist nützlich, um eine Teilliste einer Tabelle zu erhalten. |
| 253 | 253 | ||
| 254 | ```yuescript | 254 | ```yuescript |
| 255 | -- take the 2nd and 4th items as a new list | 255 | -- das 2. und 4. Element als neue Liste nehmen |
| 256 | sub_list = items[2, 4] | 256 | sub_list = items[2, 4] |
| 257 | 257 | ||
| 258 | -- take the last 4 items | 258 | -- die letzten 4 Elemente nehmen |
| 259 | last_four_items = items[-4, -1] | 259 | last_four_items = items[-4, -1] |
| 260 | ``` | 260 | ``` |
| 261 | <YueDisplay> | 261 | <YueDisplay> |
| 262 | 262 | ||
| 263 | ```yue | 263 | ```yue |
| 264 | -- take the 2nd and 4th items as a new list | 264 | -- das 2. und 4. Element als neue Liste nehmen |
| 265 | sub_list = items[2, 4] | 265 | sub_list = items[2, 4] |
| 266 | 266 | ||
| 267 | -- take the last 4 items | 267 | -- die letzten 4 Elemente nehmen |
| 268 | last_four_items = items[-4, -1] | 268 | last_four_items = items[-4, -1] |
| 269 | ``` | 269 | ``` |
| 270 | 270 | ||
diff --git a/doc/docs/de/doc/data-structures/table-literals.md b/doc/docs/de/doc/data-structures/table-literals.md index c1adcab..46181d7 100644 --- a/doc/docs/de/doc/data-structures/table-literals.md +++ b/doc/docs/de/doc/data-structures/table-literals.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Table Literals | 1 | # Tabellenliterale |
| 2 | 2 | ||
| 3 | Like in Lua, tables are delimited in curly braces. | 3 | Wie in Lua werden Tabellen mit geschweiften Klammern definiert. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| @@ -13,13 +13,13 @@ some_values = [1, 2, 3, 4] | |||
| 13 | 13 | ||
| 14 | </YueDisplay> | 14 | </YueDisplay> |
| 15 | 15 | ||
| 16 | Unlike Lua, assigning a value to a key in a table is done with **:** (instead of **=**). | 16 | Anders als in Lua weist man einem Schlüssel in einer Tabelle mit **:** (statt **=**) einen Wert zu. |
| 17 | 17 | ||
| 18 | ```yuescript | 18 | ```yuescript |
| 19 | some_values = { | 19 | some_values = { |
| 20 | name: "Bill", | 20 | name: "Bill", |
| 21 | age: 200, | 21 | age: 200, |
| 22 | ["favorite food"]: "rice" | 22 | ["Lieblingsessen"]: "Reis" |
| 23 | } | 23 | } |
| 24 | ``` | 24 | ``` |
| 25 | <YueDisplay> | 25 | <YueDisplay> |
| @@ -28,39 +28,39 @@ some_values = { | |||
| 28 | some_values = { | 28 | some_values = { |
| 29 | name: "Bill", | 29 | name: "Bill", |
| 30 | age: 200, | 30 | age: 200, |
| 31 | ["favorite food"]: "rice" | 31 | ["Lieblingsessen"]: "Reis" |
| 32 | } | 32 | } |
| 33 | ``` | 33 | ``` |
| 34 | 34 | ||
| 35 | </YueDisplay> | 35 | </YueDisplay> |
| 36 | 36 | ||
| 37 | The curly braces can be left off if a single table of key value pairs is being assigned. | 37 | Die geschweiften Klammern können weggelassen werden, wenn eine einzelne Tabelle aus Schlüssel-Wert-Paaren zugewiesen wird. |
| 38 | 38 | ||
| 39 | ```yuescript | 39 | ```yuescript |
| 40 | profile = | 40 | profile = |
| 41 | height: "4 feet", | 41 | height: "4 Fuß", |
| 42 | shoe_size: 13, | 42 | shoe_size: 13, |
| 43 | favorite_foods: ["ice cream", "donuts"] | 43 | favorite_foods: ["Eis", "Donuts"] |
| 44 | ``` | 44 | ``` |
| 45 | <YueDisplay> | 45 | <YueDisplay> |
| 46 | 46 | ||
| 47 | ```yue | 47 | ```yue |
| 48 | profile = | 48 | profile = |
| 49 | height: "4 feet", | 49 | height: "4 Fuß", |
| 50 | shoe_size: 13, | 50 | shoe_size: 13, |
| 51 | favorite_foods: ["ice cream", "donuts"] | 51 | favorite_foods: ["Eis", "Donuts"] |
| 52 | ``` | 52 | ``` |
| 53 | 53 | ||
| 54 | </YueDisplay> | 54 | </YueDisplay> |
| 55 | 55 | ||
| 56 | Newlines can be used to delimit values instead of a comma (or both): | 56 | Zeilenumbrüche können Werte statt eines Kommas trennen (oder zusätzlich): |
| 57 | 57 | ||
| 58 | ```yuescript | 58 | ```yuescript |
| 59 | values = { | 59 | values = { |
| 60 | 1, 2, 3, 4 | 60 | 1, 2, 3, 4 |
| 61 | 5, 6, 7, 8 | 61 | 5, 6, 7, 8 |
| 62 | name: "superman" | 62 | name: "Superman" |
| 63 | occupation: "crime fighting" | 63 | occupation: "Verbrechensbekämpfung" |
| 64 | } | 64 | } |
| 65 | ``` | 65 | ``` |
| 66 | <YueDisplay> | 66 | <YueDisplay> |
| @@ -69,50 +69,50 @@ values = { | |||
| 69 | values = { | 69 | values = { |
| 70 | 1, 2, 3, 4 | 70 | 1, 2, 3, 4 |
| 71 | 5, 6, 7, 8 | 71 | 5, 6, 7, 8 |
| 72 | name: "superman" | 72 | name: "Superman" |
| 73 | occupation: "crime fighting" | 73 | occupation: "Verbrechensbekämpfung" |
| 74 | } | 74 | } |
| 75 | ``` | 75 | ``` |
| 76 | 76 | ||
| 77 | </YueDisplay> | 77 | </YueDisplay> |
| 78 | 78 | ||
| 79 | When creating a single line table literal, the curly braces can also be left off: | 79 | Beim Erstellen eines einzeiligen Tabellenliterals können die geschweiften Klammern ebenfalls weggelassen werden: |
| 80 | 80 | ||
| 81 | ```yuescript | 81 | ```yuescript |
| 82 | my_function dance: "Tango", partner: "none" | 82 | my_function dance: "Tango", partner: "keiner" |
| 83 | 83 | ||
| 84 | y = type: "dog", legs: 4, tails: 1 | 84 | y = type: "Hund", legs: 4, tails: 1 |
| 85 | ``` | 85 | ``` |
| 86 | <YueDisplay> | 86 | <YueDisplay> |
| 87 | 87 | ||
| 88 | ```yue | 88 | ```yue |
| 89 | my_function dance: "Tango", partner: "none" | 89 | my_function dance: "Tango", partner: "keiner" |
| 90 | 90 | ||
| 91 | y = type: "dog", legs: 4, tails: 1 | 91 | y = type: "Hund", legs: 4, tails: 1 |
| 92 | ``` | 92 | ``` |
| 93 | 93 | ||
| 94 | </YueDisplay> | 94 | </YueDisplay> |
| 95 | 95 | ||
| 96 | The keys of a table literal can be language keywords without being escaped: | 96 | Die Schlüssel eines Tabellenliterals können Sprach-Schlüsselwörter sein, ohne sie zu escapen: |
| 97 | 97 | ||
| 98 | ```yuescript | 98 | ```yuescript |
| 99 | tbl = { | 99 | tbl = { |
| 100 | do: "something" | 100 | do: "etwas" |
| 101 | end: "hunger" | 101 | end: "Hunger" |
| 102 | } | 102 | } |
| 103 | ``` | 103 | ``` |
| 104 | <YueDisplay> | 104 | <YueDisplay> |
| 105 | 105 | ||
| 106 | ```yue | 106 | ```yue |
| 107 | tbl = { | 107 | tbl = { |
| 108 | do: "something" | 108 | do: "etwas" |
| 109 | end: "hunger" | 109 | end: "Hunger" |
| 110 | } | 110 | } |
| 111 | ``` | 111 | ``` |
| 112 | 112 | ||
| 113 | </YueDisplay> | 113 | </YueDisplay> |
| 114 | 114 | ||
| 115 | If you are constructing a table out of variables and wish the keys to be the same as the variable names, then the **:** prefix operator can be used: | 115 | Wenn du eine Tabelle aus Variablen konstruierst und die Schlüssel den Variablennamen entsprechen sollen, kannst du den Präfix-Operator **:** verwenden: |
| 116 | 116 | ||
| 117 | ```yuescript | 117 | ```yuescript |
| 118 | hair = "golden" | 118 | hair = "golden" |
| @@ -133,26 +133,26 @@ print_table :hair, :height | |||
| 133 | 133 | ||
| 134 | </YueDisplay> | 134 | </YueDisplay> |
| 135 | 135 | ||
| 136 | If you want the key of a field in the table to to be result of an expression, then you can wrap it in **[ ]**, just like in Lua. You can also use a string literal directly as a key, leaving out the square brackets. This is useful if your key has any special characters. | 136 | Wenn der Schlüssel eines Feldes das Ergebnis eines Ausdrucks sein soll, kannst du ihn wie in Lua in **[ ]** setzen. Du kannst auch ein String-Literal direkt als Schlüssel verwenden und die eckigen Klammern weglassen. Das ist nützlich, wenn dein Schlüssel Sonderzeichen enthält. |
| 137 | 137 | ||
| 138 | ```yuescript | 138 | ```yuescript |
| 139 | t = { | 139 | t = { |
| 140 | [1 + 2]: "hello" | 140 | [1 + 2]: "hallo" |
| 141 | "hello world": true | 141 | "Hallo Welt": true |
| 142 | } | 142 | } |
| 143 | ``` | 143 | ``` |
| 144 | <YueDisplay> | 144 | <YueDisplay> |
| 145 | 145 | ||
| 146 | ```yue | 146 | ```yue |
| 147 | t = { | 147 | t = { |
| 148 | [1 + 2]: "hello" | 148 | [1 + 2]: "hallo" |
| 149 | "hello world": true | 149 | "Hallo Welt": true |
| 150 | } | 150 | } |
| 151 | ``` | 151 | ``` |
| 152 | 152 | ||
| 153 | </YueDisplay> | 153 | </YueDisplay> |
| 154 | 154 | ||
| 155 | Lua tables have both an array part and a hash part, but sometimes you want to make a semantic distinction between array and hash usage when writing Lua tables. Then you can write Lua table with **[ ]** instead of **{ }** to represent an array table and writing any key value pair in a list table won't be allowed. | 155 | Lua-Tabellen haben einen Array-Teil und einen Hash-Teil, aber manchmal möchte man beim Schreiben von Lua-Tabellen eine semantische Unterscheidung zwischen Array- und Hash-Nutzung machen. Dann kannst du eine Lua-Tabelle mit **[ ]** statt **{ }** schreiben, um eine Array-Tabelle darzustellen, und das Schreiben von Schlüssel-Wert-Paaren in einer Listentabelle ist nicht erlaubt. |
| 156 | 156 | ||
| 157 | ```yuescript | 157 | ```yuescript |
| 158 | some_values = [1, 2, 3, 4] | 158 | some_values = [1, 2, 3, 4] |
diff --git a/doc/docs/de/doc/functions/backcalls.md b/doc/docs/de/doc/functions/backcalls.md index e34331e..dbac86b 100644 --- a/doc/docs/de/doc/functions/backcalls.md +++ b/doc/docs/de/doc/functions/backcalls.md | |||
| @@ -1,21 +1,21 @@ | |||
| 1 | # Backcalls | 1 | # Backcalls |
| 2 | 2 | ||
| 3 | Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent. | 3 | Backcalls werden verwendet, um Callbacks zu entkoppeln (unnesting). Sie werden mit Pfeilen nach links definiert und füllen standardmäßig als letzter Parameter einen Funktionsaufruf. Die Syntax ist weitgehend wie bei normalen Pfeilfunktionen, nur dass der Pfeil in die andere Richtung zeigt und der Funktionskörper keine Einrückung benötigt. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | x <- f | 6 | x <- f |
| 7 | print "hello" .. x | 7 | print "hallo" .. x |
| 8 | ``` | 8 | ``` |
| 9 | <YueDisplay> | 9 | <YueDisplay> |
| 10 | 10 | ||
| 11 | ```yue | 11 | ```yue |
| 12 | x <- f | 12 | x <- f |
| 13 | print "hello" .. x | 13 | print "hallo" .. x |
| 14 | ``` | 14 | ``` |
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | Fat arrow functions are also available. | 18 | Fat-Arrow-Funktionen sind ebenfalls verfügbar. |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | <= f | 21 | <= f |
| @@ -30,7 +30,7 @@ print @value | |||
| 30 | 30 | ||
| 31 | </YueDisplay> | 31 | </YueDisplay> |
| 32 | 32 | ||
| 33 | You can specify a placeholder for where you want the backcall function to go as a parameter. | 33 | Du kannst einen Platzhalter angeben, an welcher Stelle die Backcall-Funktion als Parameter eingesetzt werden soll. |
| 34 | 34 | ||
| 35 | ```yuescript | 35 | ```yuescript |
| 36 | (x) <- map _, [1, 2, 3] | 36 | (x) <- map _, [1, 2, 3] |
| @@ -45,11 +45,11 @@ x * 2 | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | If you wish to have further code after your backcalls, you can set them aside with a do statement. And the parentheses can be omitted with non-fat arrow functions. | 48 | Wenn du nach deinen Backcalls weiteren Code haben willst, kannst du sie mit einem `do`-Statement absetzen. Bei Nicht-Fat-Arrow-Funktionen können die Klammern weggelassen werden. |
| 49 | 49 | ||
| 50 | ```yuescript | 50 | ```yuescript |
| 51 | result, msg = do | 51 | result, msg = do |
| 52 | data <- readAsync "filename.txt" | 52 | data <- readAsync "dateiname.txt" |
| 53 | print data | 53 | print data |
| 54 | info <- processAsync data | 54 | info <- processAsync data |
| 55 | check info | 55 | check info |
| @@ -59,7 +59,7 @@ print result, msg | |||
| 59 | 59 | ||
| 60 | ```yue | 60 | ```yue |
| 61 | result, msg = do | 61 | result, msg = do |
| 62 | data <- readAsync "filename.txt" | 62 | data <- readAsync "dateiname.txt" |
| 63 | print data | 63 | print data |
| 64 | info <- processAsync data | 64 | info <- processAsync data |
| 65 | check info | 65 | check info |
diff --git a/doc/docs/de/doc/functions/function-literals.md b/doc/docs/de/doc/functions/function-literals.md index 316e07c..d3bfb11 100644 --- a/doc/docs/de/doc/functions/function-literals.md +++ b/doc/docs/de/doc/functions/function-literals.md | |||
| @@ -1,42 +1,42 @@ | |||
| 1 | # Function Literals | 1 | # Funktionsliterale |
| 2 | 2 | ||
| 3 | All functions are created using a function expression. A simple function is denoted using the arrow: **->**. | 3 | Alle Funktionen werden mit einem Funktionsausdruck erstellt. Eine einfache Funktion wird mit dem Pfeil **->** notiert. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- call the empty function | 7 | my_function() -- leere Funktion aufrufen |
| 8 | ``` | 8 | ``` |
| 9 | <YueDisplay> | 9 | <YueDisplay> |
| 10 | 10 | ||
| 11 | ```yue | 11 | ```yue |
| 12 | my_function = -> | 12 | my_function = -> |
| 13 | my_function() -- call the empty function | 13 | my_function() -- leere Funktion aufrufen |
| 14 | ``` | 14 | ``` |
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | The body of the function can either be one statement placed directly after the arrow, or it can be a series of statements indented on the following lines: | 18 | Der Funktionskörper kann entweder eine einzelne Anweisung direkt nach dem Pfeil sein oder aus mehreren Anweisungen bestehen, die in den folgenden Zeilen eingerückt werden: |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | func_a = -> print "hello world" | 21 | func_a = -> print "Hallo Welt" |
| 22 | 22 | ||
| 23 | func_b = -> | 23 | func_b = -> |
| 24 | value = 100 | 24 | value = 100 |
| 25 | print "The value:", value | 25 | print "Der Wert:", value |
| 26 | ``` | 26 | ``` |
| 27 | <YueDisplay> | 27 | <YueDisplay> |
| 28 | 28 | ||
| 29 | ```yue | 29 | ```yue |
| 30 | func_a = -> print "hello world" | 30 | func_a = -> print "Hallo Welt" |
| 31 | 31 | ||
| 32 | func_b = -> | 32 | func_b = -> |
| 33 | value = 100 | 33 | value = 100 |
| 34 | print "The value:", value | 34 | print "Der Wert:", value |
| 35 | ``` | 35 | ``` |
| 36 | 36 | ||
| 37 | </YueDisplay> | 37 | </YueDisplay> |
| 38 | 38 | ||
| 39 | If a function has no arguments, it can be called using the ! operator, instead of empty parentheses. The ! invocation is the preferred way to call functions with no arguments. | 39 | Wenn eine Funktion keine Argumente hat, kann sie mit dem `!`-Operator statt leerer Klammern aufgerufen werden. Der `!`-Aufruf ist die bevorzugte Art, Funktionen ohne Argumente aufzurufen. |
| 40 | 40 | ||
| 41 | ```yuescript | 41 | ```yuescript |
| 42 | func_a! | 42 | func_a! |
| @@ -51,20 +51,20 @@ func_b() | |||
| 51 | 51 | ||
| 52 | </YueDisplay> | 52 | </YueDisplay> |
| 53 | 53 | ||
| 54 | Functions with arguments can be created by preceding the arrow with a list of argument names in parentheses: | 54 | Funktionen mit Argumenten werden erstellt, indem der Pfeil von einer Argumentliste in Klammern eingeleitet wird: |
| 55 | 55 | ||
| 56 | ```yuescript | 56 | ```yuescript |
| 57 | sum = (x, y) -> print "sum", x + y | 57 | sum = (x, y) -> print "Summe", x + y |
| 58 | ``` | 58 | ``` |
| 59 | <YueDisplay> | 59 | <YueDisplay> |
| 60 | 60 | ||
| 61 | ```yue | 61 | ```yue |
| 62 | sum = (x, y) -> print "sum", x + y | 62 | sum = (x, y) -> print "Summe", x + y |
| 63 | ``` | 63 | ``` |
| 64 | 64 | ||
| 65 | </YueDisplay> | 65 | </YueDisplay> |
| 66 | 66 | ||
| 67 | Functions can be called by listing the arguments after the name of an expression that evaluates to a function. When chaining together function calls, the arguments are applied to the closest function to the left. | 67 | Funktionen können aufgerufen werden, indem die Argumente hinter dem Namen eines Ausdrucks stehen, der zu einer Funktion evaluiert. Beim Verketten mehrerer Funktionsaufrufe werden die Argumente der nächstliegenden Funktion links zugeordnet. |
| 68 | 68 | ||
| 69 | ```yuescript | 69 | ```yuescript |
| 70 | sum 10, 20 | 70 | sum 10, 20 |
| @@ -83,7 +83,7 @@ a b c "a", "b", "c" | |||
| 83 | 83 | ||
| 84 | </YueDisplay> | 84 | </YueDisplay> |
| 85 | 85 | ||
| 86 | In order to avoid ambiguity in when calling functions, parentheses can also be used to surround the arguments. This is required here in order to make sure the right arguments get sent to the right functions. | 86 | Um Mehrdeutigkeiten beim Aufruf zu vermeiden, können die Argumente auch in Klammern gesetzt werden. Das ist hier nötig, damit die richtigen Argumente an die richtigen Funktionen gehen. |
| 87 | 87 | ||
| 88 | ```yuescript | 88 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 89 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| @@ -96,24 +96,24 @@ print "x:", sum(10, 20), "y:", sum(30, 40) | |||
| 96 | 96 | ||
| 97 | </YueDisplay> | 97 | </YueDisplay> |
| 98 | 98 | ||
| 99 | There must not be any space between the opening parenthesis and the function. | 99 | Zwischen öffnender Klammer und Funktionsname darf kein Leerzeichen stehen. |
| 100 | 100 | ||
| 101 | Functions will coerce the last statement in their body into a return statement, this is called implicit return: | 101 | Funktionen wandeln die letzte Anweisung im Funktionskörper in ein `return` um. Das nennt sich implizites Return: |
| 102 | 102 | ||
| 103 | ```yuescript | 103 | ```yuescript |
| 104 | sum = (x, y) -> x + y | 104 | sum = (x, y) -> x + y |
| 105 | print "The sum is ", sum 10, 20 | 105 | print "Die Summe ist ", sum 10, 20 |
| 106 | ``` | 106 | ``` |
| 107 | <YueDisplay> | 107 | <YueDisplay> |
| 108 | 108 | ||
| 109 | ```yue | 109 | ```yue |
| 110 | sum = (x, y) -> x + y | 110 | sum = (x, y) -> x + y |
| 111 | print "The sum is ", sum 10, 20 | 111 | print "Die Summe ist ", sum 10, 20 |
| 112 | ``` | 112 | ``` |
| 113 | 113 | ||
| 114 | </YueDisplay> | 114 | </YueDisplay> |
| 115 | 115 | ||
| 116 | And if you need to explicitly return, you can use the return keyword: | 116 | Wenn du explizit zurückgeben willst, verwende `return`: |
| 117 | 117 | ||
| 118 | ```yuescript | 118 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 119 | sum = (x, y) -> return x + y |
| @@ -126,7 +126,7 @@ sum = (x, y) -> return x + y | |||
| 126 | 126 | ||
| 127 | </YueDisplay> | 127 | </YueDisplay> |
| 128 | 128 | ||
| 129 | Just like in Lua, functions can return multiple values. The last statement must be a list of values separated by commas: | 129 | Wie in Lua können Funktionen mehrere Werte zurückgeben. Die letzte Anweisung muss eine Liste von Werten sein, getrennt durch Kommas: |
| 130 | 130 | ||
| 131 | ```yuescript | 131 | ```yuescript |
| 132 | mystery = (x, y) -> x + y, x - y | 132 | mystery = (x, y) -> x + y, x - y |
| @@ -143,7 +143,7 @@ a, b = mystery 10, 20 | |||
| 143 | 143 | ||
| 144 | ## Fat Arrows | 144 | ## Fat Arrows |
| 145 | 145 | ||
| 146 | Because it is an idiom in Lua to send an object as the first argument when calling a method, a special syntax is provided for creating functions which automatically includes a self argument. | 146 | Da es in Lua üblich ist, beim Methodenaufruf ein Objekt als erstes Argument zu übergeben, gibt es eine spezielle Syntax zum Erstellen von Funktionen, die automatisch ein `self`-Argument enthalten. |
| 147 | 147 | ||
| 148 | ```yuescript | 148 | ```yuescript |
| 149 | func = (num) => @value + num | 149 | func = (num) => @value + num |
| @@ -156,26 +156,26 @@ func = (num) => @value + num | |||
| 156 | 156 | ||
| 157 | </YueDisplay> | 157 | </YueDisplay> |
| 158 | 158 | ||
| 159 | ## Argument Defaults | 159 | ## Standardwerte für Argumente |
| 160 | 160 | ||
| 161 | It is possible to provide default values for the arguments of a function. An argument is determined to be empty if its value is nil. Any nil arguments that have a default value will be replace before the body of the function is run. | 161 | Es ist möglich, Standardwerte für Funktionsargumente anzugeben. Ein Argument gilt als leer, wenn sein Wert `nil` ist. Alle `nil`-Argumente mit Standardwert werden vor Ausführung des Funktionskörpers ersetzt. |
| 162 | 162 | ||
| 163 | ```yuescript | 163 | ```yuescript |
| 164 | my_function = (name = "something", height = 100) -> | 164 | my_function = (name = "etwas", height = 100) -> |
| 165 | print "Hello I am", name | 165 | print "Hallo, ich bin", name |
| 166 | print "My height is", height | 166 | print "Meine Größe ist", height |
| 167 | ``` | 167 | ``` |
| 168 | <YueDisplay> | 168 | <YueDisplay> |
| 169 | 169 | ||
| 170 | ```yue | 170 | ```yue |
| 171 | my_function = (name = "something", height = 100) -> | 171 | my_function = (name = "etwas", height = 100) -> |
| 172 | print "Hello I am", name | 172 | print "Hallo, ich bin", name |
| 173 | print "My height is", height | 173 | print "Meine Größe ist", height |
| 174 | ``` | 174 | ``` |
| 175 | 175 | ||
| 176 | </YueDisplay> | 176 | </YueDisplay> |
| 177 | 177 | ||
| 178 | An argument default value expression is evaluated in the body of the function in the order of the argument declarations. For this reason default values have access to previously declared arguments. | 178 | Der Ausdruck für den Standardwert wird im Funktionskörper in der Reihenfolge der Argumentdeklarationen ausgewertet. Daher können Standardwerte auf zuvor deklarierte Argumente zugreifen. |
| 179 | 179 | ||
| 180 | ```yuescript | 180 | ```yuescript |
| 181 | some_args = (x = 100, y = x + 1000) -> | 181 | some_args = (x = 100, y = x + 1000) -> |
| @@ -190,11 +190,11 @@ some_args = (x = 100, y = x + 1000) -> | |||
| 190 | 190 | ||
| 191 | </YueDisplay> | 191 | </YueDisplay> |
| 192 | 192 | ||
| 193 | ## Considerations | 193 | ## Hinweise |
| 194 | 194 | ||
| 195 | Because of the expressive parentheses-less way of calling functions, some restrictions must be put in place to avoid parsing ambiguity involving whitespace. | 195 | Aufgrund der ausdrucksstarken, klammerlosen Funktionsaufrufe müssen einige Einschränkungen gelten, um Parsing-Mehrdeutigkeiten mit Leerraum zu vermeiden. |
| 196 | 196 | ||
| 197 | The minus sign plays two roles, a unary negation operator and a binary subtraction operator. Consider how the following examples compile: | 197 | Das Minuszeichen hat zwei Rollen: unäre Negation und binäre Subtraktion. Sieh dir an, wie die folgenden Beispiele kompiliert werden: |
| 198 | 198 | ||
| 199 | ```yuescript | 199 | ```yuescript |
| 200 | a = x - 10 | 200 | a = x - 10 |
| @@ -213,30 +213,30 @@ d = x- z | |||
| 213 | 213 | ||
| 214 | </YueDisplay> | 214 | </YueDisplay> |
| 215 | 215 | ||
| 216 | The precedence of the first argument of a function call can be controlled using whitespace if the argument is a literal string. In Lua, it is common to leave off parentheses when calling a function with a single string or table literal. | 216 | Die Präzedenz des ersten Arguments eines Funktionsaufrufs kann mit Leerraum gesteuert werden, wenn das Argument ein String-Literal ist. In Lua lässt man bei Aufrufen mit einem einzelnen String- oder Tabellenliteral häufig die Klammern weg. |
| 217 | 217 | ||
| 218 | When there is no space between a variable and a string literal, the function call takes precedence over any following expressions. No other arguments can be passed to the function when it is called this way. | 218 | Wenn kein Leerzeichen zwischen Variable und String-Literal steht, hat der Funktionsaufruf Vorrang vor nachfolgenden Ausdrücken. In dieser Form können keine weiteren Argumente übergeben werden. |
| 219 | 219 | ||
| 220 | Where there is a space following a variable and a string literal, the function call acts as show above. The string literal belongs to any following expressions (if they exist), which serves as the argument list. | 220 | Steht ein Leerzeichen zwischen Variable und String-Literal, verhält sich der Aufruf wie oben gezeigt. Das String-Literal gehört dann zu nachfolgenden Ausdrücken (falls vorhanden) und dient als Argumentliste. |
| 221 | 221 | ||
| 222 | ```yuescript | 222 | ```yuescript |
| 223 | x = func"hello" + 100 | 223 | x = func"hallo" + 100 |
| 224 | y = func "hello" + 100 | 224 | y = func "hallo" + 100 |
| 225 | ``` | 225 | ``` |
| 226 | <YueDisplay> | 226 | <YueDisplay> |
| 227 | 227 | ||
| 228 | ```yue | 228 | ```yue |
| 229 | x = func"hello" + 100 | 229 | x = func"hallo" + 100 |
| 230 | y = func "hello" + 100 | 230 | y = func "hallo" + 100 |
| 231 | ``` | 231 | ``` |
| 232 | 232 | ||
| 233 | </YueDisplay> | 233 | </YueDisplay> |
| 234 | 234 | ||
| 235 | ## Multi-line arguments | 235 | ## Mehrzeilige Argumente |
| 236 | 236 | ||
| 237 | When calling functions that take a large number of arguments, it is convenient to split the argument list over multiple lines. Because of the white-space sensitive nature of the language, care must be taken when splitting up the argument list. | 237 | Wenn Funktionsaufrufe viele Argumente haben, ist es praktisch, die Argumentliste auf mehrere Zeilen zu verteilen. Wegen der whitespace-sensitiven Natur der Sprache muss man dabei sorgfältig sein. |
| 238 | 238 | ||
| 239 | If an argument list is to be continued onto the next line, the current line must end in a comma. And the following line must be indented more than the current indentation. Once indented, all other argument lines must be at the same level of indentation to be part of the argument list | 239 | Wenn eine Argumentliste in der nächsten Zeile fortgesetzt wird, muss die aktuelle Zeile mit einem Komma enden. Die folgende Zeile muss stärker eingerückt sein als die aktuelle. Sobald eingerückt, müssen alle weiteren Argumentzeilen auf derselben Einrückungsebene liegen, um Teil der Argumentliste zu sein. |
| 240 | 240 | ||
| 241 | ```yuescript | 241 | ```yuescript |
| 242 | my_func 5, 4, 3, | 242 | my_func 5, 4, 3, |
| @@ -261,7 +261,7 @@ cool_func 1, 2, | |||
| 261 | 261 | ||
| 262 | </YueDisplay> | 262 | </YueDisplay> |
| 263 | 263 | ||
| 264 | This type of invocation can be nested. The level of indentation is used to determine to which function the arguments belong to. | 264 | Diese Art des Aufrufs kann verschachtelt werden. Die Einrückungsebene bestimmt, zu welcher Funktion die Argumente gehören. |
| 265 | 265 | ||
| 266 | ```yuescript | 266 | ```yuescript |
| 267 | my_func 5, 6, 7, | 267 | my_func 5, 6, 7, |
| @@ -280,7 +280,7 @@ my_func 5, 6, 7, | |||
| 280 | 280 | ||
| 281 | </YueDisplay> | 281 | </YueDisplay> |
| 282 | 282 | ||
| 283 | Because tables also use the comma as a delimiter, this indentation syntax is helpful for letting values be part of the argument list instead of being part of the table. | 283 | Da Tabellen ebenfalls das Komma als Trennzeichen verwenden, hilft diese Einrückungssyntax dabei, Werte zur Argumentliste gehören zu lassen, statt zur Tabelle. |
| 284 | 284 | ||
| 285 | ```yuescript | 285 | ```yuescript |
| 286 | x = [ | 286 | x = [ |
| @@ -301,7 +301,7 @@ x = [ | |||
| 301 | 301 | ||
| 302 | </YueDisplay> | 302 | </YueDisplay> |
| 303 | 303 | ||
| 304 | Although uncommon, notice how we can give a deeper indentation for function arguments if we know we will be using a lower indentation further on. | 304 | Obwohl es selten ist: Du kannst Funktionsargumente tiefer einrücken, wenn du weißt, dass du später eine geringere Einrückungsebene verwenden wirst. |
| 305 | 305 | ||
| 306 | ```yuescript | 306 | ```yuescript |
| 307 | y = [ my_func 1, 2, 3, | 307 | y = [ my_func 1, 2, 3, |
| @@ -320,46 +320,45 @@ y = [ my_func 1, 2, 3, | |||
| 320 | 320 | ||
| 321 | </YueDisplay> | 321 | </YueDisplay> |
| 322 | 322 | ||
| 323 | The same thing can be done with other block level statements like conditionals. We can use indentation level to determine what statement a value belongs to: | 323 | Dasselbe lässt sich mit anderen Block-Statements wie Bedingungen machen. Wir können die Einrückungsebene verwenden, um zu bestimmen, zu welcher Anweisung ein Wert gehört: |
| 324 | 324 | ||
| 325 | ```yuescript | 325 | ```yuescript |
| 326 | if func 1, 2, 3, | 326 | if func 1, 2, 3, |
| 327 | "hello", | 327 | "hallo", |
| 328 | "world" | 328 | "Welt" |
| 329 | print "hello" | 329 | print "hallo" |
| 330 | print "I am inside if" | 330 | print "Ich bin innerhalb der if-Bedingung" |
| 331 | 331 | ||
| 332 | if func 1, 2, 3, | 332 | if func 1, 2, 3, |
| 333 | "hello", | 333 | "hallo", |
| 334 | "world" | 334 | "Welt" |
| 335 | print "hello" | 335 | print "hallo" |
| 336 | print "I am inside if" | 336 | print "Ich bin innerhalb der if-Bedingung" |
| 337 | ``` | 337 | ``` |
| 338 | <YueDisplay> | 338 | <YueDisplay> |
| 339 | 339 | ||
| 340 | ```yue | 340 | ```yue |
| 341 | if func 1, 2, 3, | 341 | if func 1, 2, 3, |
| 342 | "hello", | 342 | "hallo", |
| 343 | "world" | 343 | "Welt" |
| 344 | print "hello" | 344 | print "hallo" |
| 345 | print "I am inside if" | 345 | print "Ich bin innerhalb der if-Bedingung" |
| 346 | 346 | ||
| 347 | if func 1, 2, 3, | 347 | if func 1, 2, 3, |
| 348 | "hello", | 348 | "hallo", |
| 349 | "world" | 349 | "Welt" |
| 350 | print "hello" | 350 | print "hallo" |
| 351 | print "I am inside if" | 351 | print "Ich bin innerhalb der if-Bedingung" |
| 352 | ``` | 352 | ``` |
| 353 | 353 | ||
| 354 | </YueDisplay> | 354 | </YueDisplay> |
| 355 | 355 | ||
| 356 | ## Parameter Destructuring | 356 | ## Parameter-Destructuring |
| 357 | 357 | ||
| 358 | YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available: | 358 | YueScript unterstützt jetzt Destructuring von Funktionsparametern, wenn das Argument ein Objekt ist. Es gibt zwei Formen von Destructuring-Tabellenliteralen: |
| 359 | 359 | ||
| 360 | * **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`). | 360 | * **Geschweifte Klammern/Objektparameter**, die optionale Standardwerte erlauben, wenn Felder fehlen (z. B. `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | 361 | * **Unverpackte einfache Tabellensyntax**, die mit einer Sequenz aus Key-Value- oder Shorthand-Bindings beginnt und so lange läuft, bis ein anderer Ausdruck sie beendet (z. B. `:a, b: b1, :c`). Diese Form extrahiert mehrere Felder aus demselben Objekt. | |
| 362 | * **Unwrapped simple table syntax**, starting with a sequence of key-value or shorthand bindings and continuing until another expression terminates it (e.g., `:a, b: b1, :c`). This form extracts multiple fields from the same object. | ||
| 363 | 362 | ||
| 364 | ```yuescript | 363 | ```yuescript |
| 365 | f1 = (:a, :b, :c) -> | 364 | f1 = (:a, :b, :c) -> |
| @@ -390,9 +389,9 @@ f2 arg1, arg2 | |||
| 390 | 389 | ||
| 391 | </YueDisplay> | 390 | </YueDisplay> |
| 392 | 391 | ||
| 393 | ## Prefixed Return Expression | 392 | ## Präfixiertes Return-Expression |
| 394 | 393 | ||
| 395 | When working with deeply nested function bodies, it can be tedious to maintain readability and consistency of the return value. To address this, YueScript introduces the **Prefixed Return Expression** syntax. Its form is as follows: | 394 | Wenn du mit tief verschachtelten Funktionskörpern arbeitest, kann es mühsam sein, die Lesbarkeit und Konsistenz des Rückgabewerts zu erhalten. Dafür führt YueScript die Syntax der **präfixierten Return-Expression** ein. Sie hat folgende Form: |
| 396 | 395 | ||
| 397 | ```yuescript | 396 | ```yuescript |
| 398 | findFirstEven = (list): nil -> | 397 | findFirstEven = (list): nil -> |
| @@ -415,7 +414,7 @@ findFirstEven = (list): nil -> | |||
| 415 | 414 | ||
| 416 | </YueDisplay> | 415 | </YueDisplay> |
| 417 | 416 | ||
| 418 | This is equivalent to: | 417 | Das ist äquivalent zu: |
| 419 | 418 | ||
| 420 | ```yuescript | 419 | ```yuescript |
| 421 | findFirstEven = (list) -> | 420 | findFirstEven = (list) -> |
| @@ -440,16 +439,16 @@ findFirstEven = (list) -> | |||
| 440 | 439 | ||
| 441 | </YueDisplay> | 440 | </YueDisplay> |
| 442 | 441 | ||
| 443 | The only difference is that you can move the final return expression before the `->` or `=>` token to indicate the function’s implicit return value as the last statement. This way, even in functions with multiple nested loops or conditional branches, you no longer need to write a trailing return expression at the end of the function body, making the logic structure more straightforward and easier to follow. | 442 | Der einzige Unterschied ist, dass du den finalen Rückgabeausdruck vor das `->`- oder `=>`-Token ziehen kannst, um den impliziten Rückgabewert der Funktion als letzte Anweisung zu kennzeichnen. So musst du selbst bei Funktionen mit mehreren verschachtelten Schleifen oder bedingten Zweigen kein abschließendes `return` am Ende des Funktionskörpers mehr schreiben, was die Logikstruktur klarer und leichter nachvollziehbar macht. |
| 444 | 443 | ||
| 445 | ## Named Varargs | 444 | ## Benannte Varargs |
| 446 | 445 | ||
| 447 | You can use the `(...t) ->` syntax to automatically store varargs into a named table. This table will contain all passed arguments (including `nil` values), and the `n` field of the table will store the actual number of arguments passed (including `nil` values). | 446 | Mit der Syntax `(...t) ->` kannst du Varargs automatisch in einer benannten Tabelle speichern. Diese Tabelle enthält alle übergebenen Argumente (einschließlich `nil`-Werten), und das Feld `n` der Tabelle speichert die tatsächliche Anzahl übergebener Argumente (einschließlich `nil`-Werten). |
| 448 | 447 | ||
| 449 | ```yuescript | 448 | ```yuescript |
| 450 | f = (...t) -> | 449 | f = (...t) -> |
| 451 | print "argument count:", t.n | 450 | print "Anzahl der Argumente:", t.n |
| 452 | print "table length:", #t | 451 | print "Tabellenlänge:", #t |
| 453 | for i = 1, t.n | 452 | for i = 1, t.n |
| 454 | print t[i] | 453 | print t[i] |
| 455 | 454 | ||
| @@ -457,7 +456,7 @@ f 1, 2, 3 | |||
| 457 | f "a", "b", "c", "d" | 456 | f "a", "b", "c", "d" |
| 458 | f! | 457 | f! |
| 459 | 458 | ||
| 460 | -- Handling cases with nil values | 459 | -- Fälle mit nil-Werten behandeln |
| 461 | process = (...args) -> | 460 | process = (...args) -> |
| 462 | sum = 0 | 461 | sum = 0 |
| 463 | for i = 1, args.n | 462 | for i = 1, args.n |
| @@ -471,8 +470,8 @@ process 1, nil, 3, nil, 5 | |||
| 471 | 470 | ||
| 472 | ```yue | 471 | ```yue |
| 473 | f = (...t) -> | 472 | f = (...t) -> |
| 474 | print "argument count:", t.n | 473 | print "Anzahl der Argumente:", t.n |
| 475 | print "table length:", #t | 474 | print "Tabellenlänge:", #t |
| 476 | for i = 1, t.n | 475 | for i = 1, t.n |
| 477 | print t[i] | 476 | print t[i] |
| 478 | 477 | ||
| @@ -480,7 +479,7 @@ f 1, 2, 3 | |||
| 480 | f "a", "b", "c", "d" | 479 | f "a", "b", "c", "d" |
| 481 | f! | 480 | f! |
| 482 | 481 | ||
| 483 | -- Handling cases with nil values | 482 | -- Fälle mit nil-Werten behandeln |
| 484 | process = (...args) -> | 483 | process = (...args) -> |
| 485 | sum = 0 | 484 | sum = 0 |
| 486 | for i = 1, args.n | 485 | for i = 1, args.n |
diff --git a/doc/docs/de/doc/functions/function-stubs.md b/doc/docs/de/doc/functions/function-stubs.md index 57a8b0c..66b3ddb 100644 --- a/doc/docs/de/doc/functions/function-stubs.md +++ b/doc/docs/de/doc/functions/function-stubs.md | |||
| @@ -1,27 +1,27 @@ | |||
| 1 | # Function Stubs | 1 | # Funktions-Stubs |
| 2 | 2 | ||
| 3 | It is common to pass a function from an object around as a value, for example, passing an instance method into a function as a callback. If the function expects the object it is operating on as the first argument then you must somehow bundle that object with the function so it can be called properly. | 3 | Es ist üblich, eine Funktion eines Objekts als Wert weiterzureichen, z. B. eine Instanzmethode als Callback. Wenn die Funktion das Objekt, auf dem sie arbeitet, als erstes Argument erwartet, musst du dieses Objekt irgendwie mit der Funktion bündeln, damit sie korrekt aufgerufen werden kann. |
| 4 | 4 | ||
| 5 | The function stub syntax is a shorthand for creating a new closure function that bundles both the object and function. This new function calls the wrapped function in the correct context of the object. | 5 | Die Funktions-Stub-Syntax ist eine Kurzform, um eine neue Closure-Funktion zu erstellen, die sowohl Objekt als auch Funktion bündelt. Diese neue Funktion ruft die umschlossene Funktion im richtigen Kontext des Objekts auf. |
| 6 | 6 | ||
| 7 | Its syntax is the same as calling an instance method with the \ operator but with no argument list provided. | 7 | Die Syntax entspricht dem Aufruf einer Instanzmethode mit dem `\`-Operator, jedoch ohne Argumentliste. |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | my_object = { | 10 | my_object = { |
| 11 | value: 1000 | 11 | value: 1000 |
| 12 | write: => print "the value:", @value | 12 | write: => print "der Wert:", @value |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | run_callback = (func) -> | 15 | run_callback = (func) -> |
| 16 | print "running callback..." | 16 | print "Callback wird ausgeführt..." |
| 17 | func! | 17 | func! |
| 18 | 18 | ||
| 19 | -- this will not work: | 19 | -- das funktioniert nicht: |
| 20 | -- the function has to no reference to my_object | 20 | -- die Funktion darf keine Referenz auf my_object haben |
| 21 | run_callback my_object.write | 21 | run_callback my_object.write |
| 22 | 22 | ||
| 23 | -- function stub syntax | 23 | -- Funktions-Stub-Syntax |
| 24 | -- lets us bundle the object into a new function | 24 | -- bindet das Objekt in eine neue Funktion ein |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | <YueDisplay> | 27 | <YueDisplay> |
| @@ -29,19 +29,19 @@ run_callback my_object\write | |||
| 29 | ```yue | 29 | ```yue |
| 30 | my_object = { | 30 | my_object = { |
| 31 | value: 1000 | 31 | value: 1000 |
| 32 | write: => print "the value:", @value | 32 | write: => print "der Wert:", @value |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | run_callback = (func) -> | 35 | run_callback = (func) -> |
| 36 | print "running callback..." | 36 | print "Callback wird ausgeführt..." |
| 37 | func! | 37 | func! |
| 38 | 38 | ||
| 39 | -- this will not work: | 39 | -- das funktioniert nicht: |
| 40 | -- the function has to no reference to my_object | 40 | -- die Funktion darf keine Referenz auf my_object haben |
| 41 | run_callback my_object.write | 41 | run_callback my_object.write |
| 42 | 42 | ||
| 43 | -- function stub syntax | 43 | -- Funktions-Stub-Syntax |
| 44 | -- lets us bundle the object into a new function | 44 | -- bindet das Objekt in eine neue Funktion ein |
| 45 | run_callback my_object\write | 45 | run_callback my_object\write |
| 46 | ``` | 46 | ``` |
| 47 | 47 | ||
diff --git a/doc/docs/de/doc/getting-started/installation.md b/doc/docs/de/doc/getting-started/installation.md index a93ddfd..78187c7 100644 --- a/doc/docs/de/doc/getting-started/installation.md +++ b/doc/docs/de/doc/getting-started/installation.md | |||
| @@ -1,43 +1,43 @@ | |||
| 1 | # Installation | 1 | # Installation |
| 2 | 2 | ||
| 3 | ## Lua Module | 3 | ## Lua-Modul |
| 4 | 4 | ||
| 5 | Install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module and executable with: | 5 | Installiere [luarocks](https://luarocks.org), einen Paketmanager für Lua-Module. Installiere YueScript dann als Lua-Modul und ausführbare Datei mit: |
| 6 | 6 | ||
| 7 | ```shell | 7 | ```shell |
| 8 | luarocks install yuescript | 8 | luarocks install yuescript |
| 9 | ``` | 9 | ``` |
| 10 | 10 | ||
| 11 | Or you can build `yue.so` file with: | 11 | Oder du kannst die Datei `yue.so` bauen mit: |
| 12 | 12 | ||
| 13 | ```shell | 13 | ```shell |
| 14 | make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua | 14 | make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua |
| 15 | ``` | 15 | ``` |
| 16 | 16 | ||
| 17 | Then get the binary file from path **bin/shared/yue.so**. | 17 | Anschließend findest du die Binärdatei unter **bin/shared/yue.so**. |
| 18 | 18 | ||
| 19 | ## Build Binary Tool | 19 | ## Binär-Tool bauen |
| 20 | 20 | ||
| 21 | Clone this repo, then build and install executable with: | 21 | Klone dieses Repo und baue/installiere die ausführbare Datei mit: |
| 22 | 22 | ||
| 23 | ```shell | 23 | ```shell |
| 24 | make install | 24 | make install |
| 25 | ``` | 25 | ``` |
| 26 | 26 | ||
| 27 | Build YueScript tool without macro feature: | 27 | YueScript-Tool ohne Makro-Feature bauen: |
| 28 | 28 | ||
| 29 | ```shell | 29 | ```shell |
| 30 | make install NO_MACRO=true | 30 | make install NO_MACRO=true |
| 31 | ``` | 31 | ``` |
| 32 | 32 | ||
| 33 | Build YueScript tool without built-in Lua binary: | 33 | YueScript-Tool ohne eingebautes Lua-Binary bauen: |
| 34 | 34 | ||
| 35 | ```shell | 35 | ```shell |
| 36 | make install NO_LUA=true | 36 | make install NO_LUA=true |
| 37 | ``` | 37 | ``` |
| 38 | 38 | ||
| 39 | ## Download Precompiled Binary | 39 | ## Vorgefertigtes Binary herunterladen |
| 40 | 40 | ||
| 41 | You can download precompiled binary files, including binary executable files compatible with different Lua versions and library files. | 41 | Du kannst vorkompilierte Binärdateien herunterladen, inklusive ausführbarer Dateien für unterschiedliche Lua-Versionen und Bibliotheksdateien. |
| 42 | 42 | ||
| 43 | Download precompiled binary files from [here](https://github.com/IppClub/YueScript/releases). | 43 | Lade vorkompilierte Binärdateien von [hier](https://github.com/IppClub/YueScript/releases) herunter. |
diff --git a/doc/docs/de/doc/getting-started/introduction.md b/doc/docs/de/doc/getting-started/introduction.md index a9a9389..38354c1 100644 --- a/doc/docs/de/doc/getting-started/introduction.md +++ b/doc/docs/de/doc/getting-started/introduction.md | |||
| @@ -1,27 +1,27 @@ | |||
| 1 | # Introduction | 1 | # Einführung |
| 2 | 2 | ||
| 3 | YueScript is a dynamic language that compiles to Lua. And it's a [MoonScript](https://github.com/leafo/moonscript) dialect. The codes written in YueScript are expressive and extremely concise. And it is suitable for writing some changing application logic with more maintainable codes and runs in a Lua embeded environment such as games or website servers. | 3 | YueScript ist eine dynamische Sprache, die zu Lua kompiliert. Sie ist ein Dialekt von [MoonScript](https://github.com/leafo/moonscript). Code, der in YueScript geschrieben wird, ist ausdrucksstark und sehr kompakt. YueScript eignet sich zum Schreiben von veränderlicher Anwendungslogik mit besser wartbarem Code und läuft in eingebetteten Lua-Umgebungen wie Spielen oder Webservern. |
| 4 | 4 | ||
| 5 | Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ]. | 5 | Yue (月) ist das chinesische Wort für Mond und wird als [jyɛ] ausgesprochen. |
| 6 | 6 | ||
| 7 | ## An Overview of YueScript | 7 | ## Ein Überblick über YueScript |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | -- import syntax | 10 | -- Import-Syntax |
| 11 | import p, to_lua from "yue" | 11 | import p, to_lua from "yue" |
| 12 | 12 | ||
| 13 | -- object literals | 13 | -- Objekt-Literale |
| 14 | inventory = | 14 | inventory = |
| 15 | equipment: | 15 | equipment: |
| 16 | - "sword" | 16 | - "Schwert" |
| 17 | - "shield" | 17 | - "Schild" |
| 18 | items: | 18 | items: |
| 19 | - name: "potion" | 19 | - name: "Trank" |
| 20 | count: 10 | 20 | count: 10 |
| 21 | - name: "bread" | 21 | - name: "Brot" |
| 22 | count: 3 | 22 | count: 3 |
| 23 | 23 | ||
| 24 | -- list comprehension | 24 | -- Listen-Abstraktion |
| 25 | map = (arr, action) -> | 25 | map = (arr, action) -> |
| 26 | [action item for item in *arr] | 26 | [action item for item in *arr] |
| 27 | 27 | ||
| @@ -31,14 +31,14 @@ filter = (arr, cond) -> | |||
| 31 | reduce = (arr, init, action): init -> | 31 | reduce = (arr, init, action): init -> |
| 32 | init = action init, item for item in *arr | 32 | init = action init, item for item in *arr |
| 33 | 33 | ||
| 34 | -- pipe operator | 34 | -- Pipe-Operator |
| 35 | [1, 2, 3] | 35 | [1, 2, 3] |
| 36 | |> map (x) -> x * 2 | 36 | |> map (x) -> x * 2 |
| 37 | |> filter (x) -> x > 4 | 37 | |> filter (x) -> x > 4 |
| 38 | |> reduce 0, (a, b) -> a + b | 38 | |> reduce 0, (a, b) -> a + b |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | -- metatable manipulation | 41 | -- Metatable-Manipulation |
| 42 | apple = | 42 | apple = |
| 43 | size: 15 | 43 | size: 15 |
| 44 | <index>: | 44 | <index>: |
| @@ -47,28 +47,28 @@ apple = | |||
| 47 | with apple | 47 | with apple |
| 48 | p .size, .color, .<index> if .<>? | 48 | p .size, .color, .<index> if .<>? |
| 49 | 49 | ||
| 50 | -- js-like export syntax | 50 | -- export-Syntax (ähnlich wie in JavaScript) |
| 51 | export 🌛 = "月之脚本" | 51 | export 🌛 = "Skript des Mondes" |
| 52 | ``` | 52 | ``` |
| 53 | 53 | ||
| 54 | <YueDisplay> | 54 | <YueDisplay> |
| 55 | 55 | ||
| 56 | ```yue | 56 | ```yue |
| 57 | -- import syntax | 57 | -- Import-Syntax |
| 58 | import p, to_lua from "yue" | 58 | import p, to_lua from "yue" |
| 59 | 59 | ||
| 60 | -- object literals | 60 | -- Objekt-Literale |
| 61 | inventory = | 61 | inventory = |
| 62 | equipment: | 62 | equipment: |
| 63 | - "sword" | 63 | - "Schwert" |
| 64 | - "shield" | 64 | - "Schild" |
| 65 | items: | 65 | items: |
| 66 | - name: "potion" | 66 | - name: "Trank" |
| 67 | count: 10 | 67 | count: 10 |
| 68 | - name: "bread" | 68 | - name: "Brot" |
| 69 | count: 3 | 69 | count: 3 |
| 70 | 70 | ||
| 71 | -- list comprehension | 71 | -- Listen-Abstraktion |
| 72 | map = (arr, action) -> | 72 | map = (arr, action) -> |
| 73 | [action item for item in *arr] | 73 | [action item for item in *arr] |
| 74 | 74 | ||
| @@ -78,14 +78,14 @@ filter = (arr, cond) -> | |||
| 78 | reduce = (arr, init, action): init -> | 78 | reduce = (arr, init, action): init -> |
| 79 | init = action init, item for item in *arr | 79 | init = action init, item for item in *arr |
| 80 | 80 | ||
| 81 | -- pipe operator | 81 | -- Pipe-Operator |
| 82 | [1, 2, 3] | 82 | [1, 2, 3] |
| 83 | |> map (x) -> x * 2 | 83 | |> map (x) -> x * 2 |
| 84 | |> filter (x) -> x > 4 | 84 | |> filter (x) -> x > 4 |
| 85 | |> reduce 0, (a, b) -> a + b | 85 | |> reduce 0, (a, b) -> a + b |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | -- metatable manipulation | 88 | -- Metatable-Manipulation |
| 89 | apple = | 89 | apple = |
| 90 | size: 15 | 90 | size: 15 |
| 91 | <index>: | 91 | <index>: |
| @@ -94,12 +94,12 @@ apple = | |||
| 94 | with apple | 94 | with apple |
| 95 | p .size, .color, .<index> if .<>? | 95 | p .size, .color, .<index> if .<>? |
| 96 | 96 | ||
| 97 | -- js-like export syntax | 97 | -- export-Syntax (ähnlich wie in JavaScript) |
| 98 | export 🌛 = "月之脚本" | 98 | export 🌛 = "Skript des Mondes" |
| 99 | ``` | 99 | ``` |
| 100 | 100 | ||
| 101 | </YueDisplay> | 101 | </YueDisplay> |
| 102 | 102 | ||
| 103 | ## About Dora SSR | 103 | ## Über Dora SSR |
| 104 | 104 | ||
| 105 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/Dora-SSR/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. \ No newline at end of file | 105 | YueScript wird zusammen mit der Open-Source-Spiel-Engine [Dora SSR](https://github.com/Dora-SSR/Dora-SSR) entwickelt und gepflegt. Es wird zum Erstellen von Engine-Tools, Spiel-Demos und Prototypen eingesetzt und hat seine Leistungsfähigkeit in realen Szenarien unter Beweis gestellt, während es gleichzeitig die Dora-SSR-Entwicklungserfahrung verbessert. |
diff --git a/doc/docs/de/doc/getting-started/usage.md b/doc/docs/de/doc/getting-started/usage.md index 45161c6..f3c9333 100644 --- a/doc/docs/de/doc/getting-started/usage.md +++ b/doc/docs/de/doc/getting-started/usage.md | |||
| @@ -1,20 +1,20 @@ | |||
| 1 | # Usage | 1 | # Verwendung |
| 2 | 2 | ||
| 3 | ## Lua Module | 3 | ## Lua-Modul |
| 4 | 4 | ||
| 5 | Use YueScript module in Lua: | 5 | YueScript-Modul in Lua verwenden: |
| 6 | 6 | ||
| 7 | * **Case 1** | 7 | * **Fall 1** |
| 8 | 8 | ||
| 9 | Require "your_yuescript_entry.yue" in Lua. | 9 | "your_yuescript_entry.yue" in Lua require'n. |
| 10 | ```Lua | 10 | ```Lua |
| 11 | require("yue")("your_yuescript_entry") | 11 | require("yue")("your_yuescript_entry") |
| 12 | ``` | 12 | ``` |
| 13 | And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest YueScript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly. | 13 | Dieser Code funktioniert weiterhin, wenn du "your_yuescript_entry.yue" im gleichen Pfad zu "your_yuescript_entry.lua" kompilierst. In den restlichen YueScript-Dateien verwendest du einfach normales **require** oder **import**. Die Zeilennummern in Fehlermeldungen werden korrekt behandelt. |
| 14 | 14 | ||
| 15 | * **Case 2** | 15 | * **Fall 2** |
| 16 | 16 | ||
| 17 | Require YueScript module and rewite message by hand. | 17 | YueScript-Modul require'n und das Fehlermapping manuell umschreiben. |
| 18 | 18 | ||
| 19 | ```lua | 19 | ```lua |
| 20 | local yue = require("yue") | 20 | local yue = require("yue") |
| @@ -26,15 +26,15 @@ Use YueScript module in Lua: | |||
| 26 | end) | 26 | end) |
| 27 | ``` | 27 | ``` |
| 28 | 28 | ||
| 29 | * **Case 3** | 29 | * **Fall 3** |
| 30 | 30 | ||
| 31 | Use the YueScript compiler function in Lua. | 31 | Die YueScript-Compilerfunktion in Lua verwenden. |
| 32 | 32 | ||
| 33 | ```lua | 33 | ```lua |
| 34 | local yue = require("yue") | 34 | local yue = require("yue") |
| 35 | local codes, err, globals = yue.to_lua([[ | 35 | local codes, err, globals = yue.to_lua([[ |
| 36 | f = -> | 36 | f = -> |
| 37 | print "hello world" | 37 | print "Hallo Welt" |
| 38 | f! | 38 | f! |
| 39 | ]],{ | 39 | ]],{ |
| 40 | implicit_return_root = true, | 40 | implicit_return_root = true, |
| @@ -48,64 +48,66 @@ Use YueScript module in Lua: | |||
| 48 | }) | 48 | }) |
| 49 | ``` | 49 | ``` |
| 50 | 50 | ||
| 51 | ## YueScript Tool | 51 | ## YueScript-Tool |
| 52 | 52 | ||
| 53 | Use YueScript tool with: | 53 | YueScript-Tool verwenden mit: |
| 54 | 54 | ||
| 55 | ```shell | 55 | ```shell |
| 56 | > yue -h | 56 | > yue -h |
| 57 | Usage: yue | 57 | Verwendung: yue |
| 58 | [options] [<file/directory>] ... | 58 | [Optionen] [<Datei/Verzeichnis>] ... |
| 59 | yue -e <code_or_file> [args...] | 59 | yue -e <code_oder_datei> [argumente...] |
| 60 | yue -w [<directory>] [options] | 60 | yue -w [<verzeichnis>] [optionen] |
| 61 | yue - | 61 | yue - |
| 62 | 62 | ||
| 63 | Notes: | 63 | Hinweise: |
| 64 | - '-' / '--' must be the first and only argument. | 64 | - '-' / '--' muss das erste und einzige Argument sein. |
| 65 | - '-o/--output' can not be used with multiple input files. | 65 | - '-o/--output' kann nicht mit mehreren Eingabedateien verwendet werden. |
| 66 | - '-w/--watch' can not be used with file input (directory only). | 66 | - '-w/--watch' kann nicht mit Dateieingabe verwendet werden (nur Verzeichnisse). |
| 67 | - with '-e/--execute', remaining tokens are treated as script args. | 67 | - Mit '-e/--execute' werden verbleibende Tokens als Skriptargumente behandelt. |
| 68 | 68 | ||
| 69 | Options: | 69 | Optionen: |
| 70 | -h, --help Show this help message and exit. | 70 | -h, --help Zeigt diese Hilfemeldung an und beendet das Programm. |
| 71 | -e <str>, --execute <str> Execute a file or raw codes | 71 | -e <str>, --execute <str> Datei oder Quellcode ausführen |
| 72 | -m, --minify Generate minified codes | 72 | -m, --minify Minimierten Code erzeugen |
| 73 | -r, --rewrite Rewrite output to match original line numbers | 73 | -r, --rewrite Ausgabe so umschreiben, dass die Zeilennummern dem Original entsprechen |
| 74 | -t <output_to>, --output-to <output_to> | 74 | -t <ziel>, --output-to <ziel> |
| 75 | Specify where to place compiled files | 75 | Ziel für kompilierte Dateien angeben |
| 76 | -o <file>, --output <file> Write output to file | 76 | -o <datei>, --output <datei> |
| 77 | -p, --print Write output to standard out | 77 | Schreibe die Ausgabe in eine Datei |
| 78 | -b, --benchmark Dump compile time (doesn't write output) | 78 | -p, --print Schreibe die Ausgabe auf die Standardausgabe |
| 79 | -g, --globals Dump global variables used in NAME LINE COLUMN | 79 | -b, --benchmark Gibt die Kompilierungszeit aus (keine Ausgabe schreiben) |
| 80 | -s, --spaces Use spaces in generated codes instead of tabs | 80 | -g, --globals Gibt verwendete globale Variablen im Format NAME ZEILE SPALTE aus |
| 81 | -l, --line-numbers Write line numbers from source codes | 81 | -s, --spaces Verwende Leerzeichen anstelle von Tabs im generierten Code |
| 82 | -j, --no-implicit-return Disable implicit return at end of file | 82 | -l, --line-numbers Schreibe Zeilennummern aus dem Quellcode |
| 83 | -c, --reserve-comments Reserve comments before statement from source codes | 83 | -j, --no-implicit-return Deaktiviert implizites Rückgabe am Datei-Ende |
| 84 | -w [<dir>], --watch [<dir>] | 84 | -c, --reserve-comments Kommentare aus dem Quellcode vor Anweisungen beibehalten |
| 85 | Watch changes and compile every file under directory | 85 | -w [<verz>], --watch [<verz>] |
| 86 | -v, --version Print version | 86 | Änderungen beobachten und alle Dateien im Verzeichnis kompilieren |
| 87 | - Read from standard in, print to standard out | 87 | -v, --version Version ausgeben |
| 88 | (Must be first and only argument) | 88 | - Lese von Standardinput, schreibe auf Standardausgabe |
| 89 | -- Same as '-' (kept for backward compatibility) | 89 | (muss das erste und einzige Argument sein) |
| 90 | 90 | -- Wie '-', bleibt zur Abwärtskompatibilität bestehen | |
| 91 | --target <version> Specify the Lua version that codes will be generated to | 91 | |
| 92 | (version can only be 5.1 to 5.5) | 92 | --target <version> Gib an, welche Lua-Version erzeugt werden soll |
| 93 | --path <path_str> Append an extra Lua search path string to package.path | 93 | (Version nur von 5.1 bis 5.5 möglich) |
| 94 | --<key>=<value> Pass compiler option in key=value form (existing behavior) | 94 | --path <pfad_str> Füge einen zusätzlichen Lua-Suchpfad zu package.path hinzu |
| 95 | 95 | --<schlüssel>=<wert> Übertrage Compileroption im Schlüssel=Wert-Format (bestehendes Verhalten) | |
| 96 | Execute without options to enter REPL, type symbol '$' | 96 | |
| 97 | in a single line to start/stop multi-line mode | 97 | Ohne Optionen wird die REPL gestartet, gebe das Symbol '$' |
| 98 | in eine einzelne Zeile ein, um den Multi-Line-Modus zu starten/beenden | ||
| 98 | ``` | 99 | ``` |
| 99 | Use cases: | ||
| 100 | 100 | ||
| 101 | Recursively compile every YueScript file with extension **.yue** under current path: **yue .** | 101 | Anwendungsfälle: |
| 102 | 102 | ||
| 103 | Compile and save results to a target path: **yue -t /target/path/ .** | 103 | Rekursiv jede YueScript-Datei mit der Endung **.yue** unter dem aktuellen Pfad kompilieren: **yue .** |
| 104 | 104 | ||
| 105 | Compile and reserve debug info: **yue -l .** | 105 | Kompilieren und Ergebnisse in einen Zielpfad schreiben: **yue -t /target/path/ .** |
| 106 | 106 | ||
| 107 | Compile and generate minified codes: **yue -m .** | 107 | Kompilieren und Debug-Infos beibehalten: **yue -l .** |
| 108 | 108 | ||
| 109 | Execute raw codes: **yue -e 'print 123'** | 109 | Kompilieren und minifizierten Code erzeugen: **yue -m .** |
| 110 | 110 | ||
| 111 | Execute a YueScript file: **yue -e main.yue** | 111 | Rohcode ausführen: **yue -e 'print 123'** |
| 112 | |||
| 113 | Eine YueScript-Datei ausführen: **yue -e main.yue** | ||
diff --git a/doc/docs/de/doc/language-basics/attributes.md b/doc/docs/de/doc/language-basics/attributes.md index e6fd5a7..0fa3654 100644 --- a/doc/docs/de/doc/language-basics/attributes.md +++ b/doc/docs/de/doc/language-basics/attributes.md | |||
| @@ -1,21 +1,21 @@ | |||
| 1 | # Attributes | 1 | # Attribute |
| 2 | 2 | ||
| 3 | Syntax support for Lua 5.4 attributes. And you can still use both the `const` and `close` declaration and get constant check and scoped callback working when targeting Lua versions below 5.4. | 3 | Syntax-Unterstützung für Lua-5.4-Attribute. Du kannst weiterhin die Deklarationen `const` und `close` verwenden und erhältst Konstantenprüfung sowie Scoped-Callbacks, wenn du auf Lua-Versionen unter 5.4 zielst. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | const a = 123 | 6 | const a = 123 |
| 7 | close _ = <close>: -> print "Out of scope." | 7 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs." |
| 8 | ``` | 8 | ``` |
| 9 | <YueDisplay> | 9 | <YueDisplay> |
| 10 | 10 | ||
| 11 | ```yue | 11 | ```yue |
| 12 | const a = 123 | 12 | const a = 123 |
| 13 | close _ = <close>: -> print "Out of scope." | 13 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs." |
| 14 | ``` | 14 | ``` |
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | You can do desctructuring with variables attributed as constant. | 18 | Du kannst Destructuring mit als konstant markierten Variablen verwenden. |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | const {:a, :b, c, d} = tb | 21 | const {:a, :b, c, d} = tb |
| @@ -30,7 +30,7 @@ const {:a, :b, c, d} = tb | |||
| 30 | 30 | ||
| 31 | </YueDisplay> | 31 | </YueDisplay> |
| 32 | 32 | ||
| 33 | You can also declare a global variable to be `const`. | 33 | Du kannst auch eine globale Variable als `const` deklarieren. |
| 34 | 34 | ||
| 35 | ```yuescript | 35 | ```yuescript |
| 36 | global const Constant = 123 | 36 | global const Constant = 123 |
diff --git a/doc/docs/de/doc/language-basics/comment.md b/doc/docs/de/doc/language-basics/comment.md index b67c97d..dec9bb0 100644 --- a/doc/docs/de/doc/language-basics/comment.md +++ b/doc/docs/de/doc/language-basics/comment.md | |||
| @@ -1,30 +1,30 @@ | |||
| 1 | # Comment | 1 | # Kommentare |
| 2 | 2 | ||
| 3 | ```yuescript | 3 | ```yuescript |
| 4 | -- I am a comment | 4 | -- Ich bin ein Kommentar |
| 5 | 5 | ||
| 6 | str = --[[ | 6 | str = --[[ |
| 7 | This is a multi-line comment. | 7 | Dies ist ein mehrzeiliger Kommentar. |
| 8 | It's OK. | 8 | Alles okay. |
| 9 | ]] strA \ -- comment 1 | 9 | ]] strA \ -- Kommentar 1 |
| 10 | .. strB \ -- comment 2 | 10 | .. strB \ -- Kommentar 2 |
| 11 | .. strC | 11 | .. strC |
| 12 | 12 | ||
| 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[Port]] 3000, --[[IP]] "192.168.1.1" |
| 14 | ``` | 14 | ``` |
| 15 | <YueDisplay> | 15 | <YueDisplay> |
| 16 | 16 | ||
| 17 | ```yue | 17 | ```yue |
| 18 | -- I am a comment | 18 | -- Ich bin ein Kommentar |
| 19 | 19 | ||
| 20 | str = --[[ | 20 | str = --[[ |
| 21 | This is a multi-line comment. | 21 | Dies ist ein mehrzeiliger Kommentar. |
| 22 | It's OK. | 22 | Alles okay. |
| 23 | ]] strA \ -- comment 1 | 23 | ]] strA \ -- Kommentar 1 |
| 24 | .. strB \ -- comment 2 | 24 | .. strB \ -- Kommentar 2 |
| 25 | .. strC | 25 | .. strC |
| 26 | 26 | ||
| 27 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 27 | func --[[Port]] 3000, --[[IP]] "192.168.1.1" |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | </YueDisplay> | 30 | </YueDisplay> |
diff --git a/doc/docs/de/doc/language-basics/literals.md b/doc/docs/de/doc/language-basics/literals.md index e097c62..55a5aaa 100644 --- a/doc/docs/de/doc/language-basics/literals.md +++ b/doc/docs/de/doc/language-basics/literals.md | |||
| @@ -1,33 +1,33 @@ | |||
| 1 | # Literals | 1 | # Literale |
| 2 | 2 | ||
| 3 | All of the primitive literals in Lua can be used. This applies to numbers, strings, booleans, and **nil**. | 3 | Alle primitiven Literale in Lua können verwendet werden. Das gilt für Zahlen, Strings, Booleans und **nil**. |
| 4 | 4 | ||
| 5 | Unlike Lua, Line breaks are allowed inside of single and double quote strings without an escape sequence: | 5 | Anders als in Lua sind Zeilenumbrüche innerhalb einfacher und doppelter Anführungszeichen ohne Escape-Sequenz erlaubt: |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | some_string = "Here is a string | 8 | some_string = "Hier ist ein String |
| 9 | that has a line break in it." | 9 | mit einem Zeilenumbruch." |
| 10 | 10 | ||
| 11 | -- You can mix expressions into string literals using #{} syntax. | 11 | -- Mit der #{}-Syntax kannst du Ausdrücke in String-Literale einbinden. |
| 12 | -- String interpolation is only available in double quoted strings. | 12 | -- String-Interpolation gibt es nur in doppelt angeführten Strings. |
| 13 | print "I am #{math.random! * 100}% sure." | 13 | print "Ich bin mir zu #{math.random! * 100}% sicher." |
| 14 | ``` | 14 | ``` |
| 15 | <YueDisplay> | 15 | <YueDisplay> |
| 16 | 16 | ||
| 17 | ```yue | 17 | ```yue |
| 18 | some_string = "Here is a string | 18 | some_string = "Hier ist ein String |
| 19 | that has a line break in it." | 19 | mit einem Zeilenumbruch." |
| 20 | 20 | ||
| 21 | -- You can mix expressions into string literals using #{} syntax. | 21 | -- Mit der #{}-Syntax kannst du Ausdrücke in String-Literale einbinden. |
| 22 | -- String interpolation is only available in double quoted strings. | 22 | -- String-Interpolation gibt es nur in doppelt angeführten Strings. |
| 23 | print "I am #{math.random! * 100}% sure." | 23 | print "Ich bin mir zu #{math.random! * 100}% sicher." |
| 24 | ``` | 24 | ``` |
| 25 | 25 | ||
| 26 | </YueDisplay> | 26 | </YueDisplay> |
| 27 | 27 | ||
| 28 | ## Number Literals | 28 | ## Zahlenliterale |
| 29 | 29 | ||
| 30 | You can use underscores in a number literal to increase readability. | 30 | Du kannst Unterstriche in Zahlenliteralen verwenden, um die Lesbarkeit zu erhöhen. |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | integer = 1_000_000 | 33 | integer = 1_000_000 |
| @@ -44,9 +44,9 @@ binary = 0B10011 | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | ## YAML Multiline String | 47 | ## YAML-Mehrzeilen-String |
| 48 | 48 | ||
| 49 | The `|` prefix introduces a YAML-style multiline string literal: | 49 | Das Präfix `|` führt ein mehrzeiliges String-Literal im YAML-Stil ein: |
| 50 | 50 | ||
| 51 | ```yuescript | 51 | ```yuescript |
| 52 | str = | | 52 | str = | |
| @@ -67,9 +67,9 @@ str = | | |||
| 67 | 67 | ||
| 68 | </YueDisplay> | 68 | </YueDisplay> |
| 69 | 69 | ||
| 70 | This allows writing structured multiline text conveniently. All line breaks and indentation are preserved relative to the first non-empty line, and expressions inside `#{...}` are interpolated automatically as `tostring(expr)`. | 70 | Damit lässt sich strukturierter, mehrzeiliger Text bequem schreiben. Alle Zeilenumbrüche und Einrückungen bleiben relativ zur ersten nicht-leeren Zeile erhalten, und Ausdrücke innerhalb von `#{...}` werden automatisch als `tostring(expr)` interpoliert. |
| 71 | 71 | ||
| 72 | YAML Multiline String automatically detects the common leading whitespace prefix (minimum indentation across all non-empty lines) and removes it from all lines. This makes it easy to indent your code visually without affecting the resulting string content. | 72 | Der YAML-Mehrzeilen-String erkennt automatisch das gemeinsame führende Leerraumpräfix (minimale Einrückung über alle nicht-leeren Zeilen) und entfernt es aus allen Zeilen. So kannst du deinen Code optisch einrücken, ohne den resultierenden String zu verändern. |
| 73 | 73 | ||
| 74 | ```yuescript | 74 | ```yuescript |
| 75 | fn = -> | 75 | fn = -> |
| @@ -90,9 +90,9 @@ fn = -> | |||
| 90 | 90 | ||
| 91 | </YueDisplay> | 91 | </YueDisplay> |
| 92 | 92 | ||
| 93 | Internal indentation is preserved relative to the removed common prefix, allowing clean nested structures. | 93 | Die interne Einrückung bleibt relativ zum entfernten gemeinsamen Präfix erhalten, wodurch saubere, verschachtelte Strukturen möglich sind. |
| 94 | 94 | ||
| 95 | All special characters like quotes (`"`) and backslashes (`\`) in the YAMLMultiline block are automatically escaped so that the generated Lua string is syntactically valid and behaves as expected. | 95 | Alle Sonderzeichen wie Anführungszeichen (`"`) und Backslashes (`\`) im YAML-Mehrzeilen-Block werden automatisch escaped, sodass der erzeugte Lua-String syntaktisch korrekt ist und wie erwartet funktioniert. |
| 96 | 96 | ||
| 97 | ```yuescript | 97 | ```yuescript |
| 98 | str = | | 98 | str = | |
diff --git a/doc/docs/de/doc/language-basics/operator.md b/doc/docs/de/doc/language-basics/operator.md index 9a2e89b..a7b8c5c 100644 --- a/doc/docs/de/doc/language-basics/operator.md +++ b/doc/docs/de/doc/language-basics/operator.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Operator | 1 | # Operatoren |
| 2 | 2 | ||
| 3 | All of Lua's binary and unary operators are available. Additionally **!=** is as an alias for **~=**, and either **\\** or **::** can be used to write a chaining function call like `tb\func!` or `tb::func!`. And Yuescipt offers some other special operators to write more expressive codes. | 3 | Alle binären und unären Operatoren von Lua sind verfügbar. Zusätzlich ist **!=** ein Alias für **~=**, und entweder **\** oder **::** kann für verkettete Funktionsaufrufe wie `tb\func!` oder `tb::func!` verwendet werden. Außerdem bietet YueScript einige spezielle Operatoren für ausdrucksstärkeren Code. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| @@ -15,32 +15,32 @@ tb::func! if tb != nil | |||
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | ## Chaining Comparisons | 18 | ## Verkettete Vergleiche |
| 19 | 19 | ||
| 20 | Comparisons can be arbitrarily chained: | 20 | Vergleiche können beliebig verkettet werden: |
| 21 | 21 | ||
| 22 | ```yuescript | 22 | ```yuescript |
| 23 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 | 23 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 |
| 24 | -- output: true | 24 | -- Ausgabe: true |
| 25 | 25 | ||
| 26 | a = 5 | 26 | a = 5 |
| 27 | print 1 <= a <= 10 | 27 | print 1 <= a <= 10 |
| 28 | -- output: true | 28 | -- Ausgabe: true |
| 29 | ``` | 29 | ``` |
| 30 | <YueDisplay> | 30 | <YueDisplay> |
| 31 | 31 | ||
| 32 | ```yue | 32 | ```yue |
| 33 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 | 33 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 |
| 34 | -- output: true | 34 | -- Ausgabe: true |
| 35 | 35 | ||
| 36 | a = 5 | 36 | a = 5 |
| 37 | print 1 <= a <= 10 | 37 | print 1 <= a <= 10 |
| 38 | -- output: true | 38 | -- Ausgabe: true |
| 39 | ``` | 39 | ``` |
| 40 | 40 | ||
| 41 | </YueDisplay> | 41 | </YueDisplay> |
| 42 | 42 | ||
| 43 | Note the evaluation behavior of chained comparisons: | 43 | Beachte das Auswertungsverhalten verketteter Vergleiche: |
| 44 | 44 | ||
| 45 | ```yuescript | 45 | ```yuescript |
| 46 | v = (x) -> | 46 | v = (x) -> |
| @@ -49,7 +49,7 @@ v = (x) -> | |||
| 49 | 49 | ||
| 50 | print v(1) < v(2) <= v(3) | 50 | print v(1) < v(2) <= v(3) |
| 51 | --[[ | 51 | --[[ |
| 52 | output: | 52 | Ausgabe: |
| 53 | 2 | 53 | 2 |
| 54 | 1 | 54 | 1 |
| 55 | 3 | 55 | 3 |
| @@ -58,7 +58,7 @@ print v(1) < v(2) <= v(3) | |||
| 58 | 58 | ||
| 59 | print v(1) > v(2) <= v(3) | 59 | print v(1) > v(2) <= v(3) |
| 60 | --[[ | 60 | --[[ |
| 61 | output: | 61 | Ausgabe: |
| 62 | 2 | 62 | 2 |
| 63 | 1 | 63 | 1 |
| 64 | false | 64 | false |
| @@ -73,7 +73,7 @@ v = (x) -> | |||
| 73 | 73 | ||
| 74 | print v(1) < v(2) <= v(3) | 74 | print v(1) < v(2) <= v(3) |
| 75 | --[[ | 75 | --[[ |
| 76 | output: | 76 | Ausgabe: |
| 77 | 2 | 77 | 2 |
| 78 | 1 | 78 | 1 |
| 79 | 3 | 79 | 3 |
| @@ -82,7 +82,7 @@ print v(1) < v(2) <= v(3) | |||
| 82 | 82 | ||
| 83 | print v(1) > v(2) <= v(3) | 83 | print v(1) > v(2) <= v(3) |
| 84 | --[[ | 84 | --[[ |
| 85 | output: | 85 | Ausgabe: |
| 86 | 2 | 86 | 2 |
| 87 | 1 | 87 | 1 |
| 88 | false | 88 | false |
| @@ -91,32 +91,32 @@ print v(1) > v(2) <= v(3) | |||
| 91 | 91 | ||
| 92 | </YueDisplay> | 92 | </YueDisplay> |
| 93 | 93 | ||
| 94 | The middle expression is only evaluated once, rather than twice as it would be if the expression were written as `v(1) < v(2) and v(2) <= v(3)`. However, the order of evaluations in a chained comparison is undefined. It is strongly recommended not to use expressions with side effects (such as printing) in chained comparisons. If side effects are required, the short-circuit `and` operator should be used explicitly. | 94 | Der mittlere Ausdruck wird nur einmal ausgewertet, nicht zweimal wie bei `v(1) < v(2) and v(2) <= v(3)`. Die Auswertungsreihenfolge in verketteten Vergleichen ist jedoch undefiniert. Es wird dringend empfohlen, in verketteten Vergleichen keine Ausdrücke mit Seiteneffekten (z. B. `print`) zu verwenden. Wenn Seiteneffekte nötig sind, sollte der Short-Circuit-Operator `and` explizit verwendet werden. |
| 95 | 95 | ||
| 96 | ## Table Appending | 96 | ## Tabellenerweiterung |
| 97 | 97 | ||
| 98 | The **[] =** operator is used to append values to tables. | 98 | Der Operator **[] =** wird verwendet, um Werte an Tabellen anzuhängen. |
| 99 | 99 | ||
| 100 | ```yuescript | 100 | ```yuescript |
| 101 | tab = [] | 101 | tab = [] |
| 102 | tab[] = "Value" | 102 | tab[] = "Wert" |
| 103 | ``` | 103 | ``` |
| 104 | <YueDisplay> | 104 | <YueDisplay> |
| 105 | 105 | ||
| 106 | ```yue | 106 | ```yue |
| 107 | tab = [] | 107 | tab = [] |
| 108 | tab[] = "Value" | 108 | tab[] = "Wert" |
| 109 | ``` | 109 | ``` |
| 110 | 110 | ||
| 111 | </YueDisplay> | 111 | </YueDisplay> |
| 112 | 112 | ||
| 113 | You can also use the spread operator `...` to append all elements from one list to another: | 113 | Du kannst auch den Spread-Operator `...` verwenden, um alle Elemente einer Liste an eine andere anzuhängen: |
| 114 | 114 | ||
| 115 | ```yuescript | 115 | ```yuescript |
| 116 | tbA = [1, 2, 3] | 116 | tbA = [1, 2, 3] |
| 117 | tbB = [4, 5, 6] | 117 | tbB = [4, 5, 6] |
| 118 | tbA[] = ...tbB | 118 | tbA[] = ...tbB |
| 119 | -- tbA is now [1, 2, 3, 4, 5, 6] | 119 | -- tbA ist jetzt [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 120 | ``` |
| 121 | <YueDisplay> | 121 | <YueDisplay> |
| 122 | 122 | ||
| @@ -124,24 +124,24 @@ tbA[] = ...tbB | |||
| 124 | tbA = [1, 2, 3] | 124 | tbA = [1, 2, 3] |
| 125 | tbB = [4, 5, 6] | 125 | tbB = [4, 5, 6] |
| 126 | tbA[] = ...tbB | 126 | tbA[] = ...tbB |
| 127 | -- tbA is now [1, 2, 3, 4, 5, 6] | 127 | -- tbA ist jetzt [1, 2, 3, 4, 5, 6] |
| 128 | ``` | 128 | ``` |
| 129 | 129 | ||
| 130 | </YueDisplay> | 130 | </YueDisplay> |
| 131 | 131 | ||
| 132 | ## Table Spreading | 132 | ## Tabellen-Spread |
| 133 | 133 | ||
| 134 | You can concatenate array tables or hash tables using spread operator `...` before expressions in table literals. | 134 | Du kannst Array-Tabellen oder Hash-Tabellen mit dem Spread-Operator `...` vor Ausdrücken in Tabellenliteralen zusammenführen. |
| 135 | 135 | ||
| 136 | ```yuescript | 136 | ```yuescript |
| 137 | parts = | 137 | parts = |
| 138 | * "shoulders" | 138 | * "Schultern" |
| 139 | * "knees" | 139 | * "Knie" |
| 140 | lyrics = | 140 | lyrics = |
| 141 | * "head" | 141 | * "Kopf" |
| 142 | * ...parts | 142 | * ...parts |
| 143 | * "and" | 143 | * "und" |
| 144 | * "toes" | 144 | * "Zehen" |
| 145 | 145 | ||
| 146 | copy = {...other} | 146 | copy = {...other} |
| 147 | 147 | ||
| @@ -153,13 +153,13 @@ merge = {...a, ...b} | |||
| 153 | 153 | ||
| 154 | ```yue | 154 | ```yue |
| 155 | parts = | 155 | parts = |
| 156 | * "shoulders" | 156 | * "Schultern" |
| 157 | * "knees" | 157 | * "Knie" |
| 158 | lyrics = | 158 | lyrics = |
| 159 | * "head" | 159 | * "Kopf" |
| 160 | * ...parts | 160 | * ...parts |
| 161 | * "and" | 161 | * "und" |
| 162 | * "toes" | 162 | * "Zehen" |
| 163 | 163 | ||
| 164 | copy = {...other} | 164 | copy = {...other} |
| 165 | 165 | ||
| @@ -170,9 +170,9 @@ merge = {...a, ...b} | |||
| 170 | 170 | ||
| 171 | </YueDisplay> | 171 | </YueDisplay> |
| 172 | 172 | ||
| 173 | ## Table Reversed Indexing | 173 | ## Umgekehrter Tabellenindex |
| 174 | 174 | ||
| 175 | You can use the **#** operator to get the last elements of a table. | 175 | Mit dem Operator **#** kannst du auf die letzten Elemente einer Tabelle zugreifen. |
| 176 | 176 | ||
| 177 | ```yuescript | 177 | ```yuescript |
| 178 | last = data.items[#] | 178 | last = data.items[#] |
| @@ -191,11 +191,11 @@ data.items[#] = 1 | |||
| 191 | 191 | ||
| 192 | ## Metatable | 192 | ## Metatable |
| 193 | 193 | ||
| 194 | The **<>** operator can be used as a shortcut for metatable manipulation. | 194 | Der Operator **<>** kann als Abkürzung für Metatable-Manipulation verwendet werden. |
| 195 | 195 | ||
| 196 | ### Metatable Creation | 196 | ### Metatable erstellen |
| 197 | 197 | ||
| 198 | Create normal table with empty bracekets **<>** or metamethod key which is surrounded by **<>**. | 198 | Erzeuge eine normale Tabelle mit leeren Klammern **<>** oder einem Metamethod-Schlüssel, der von **<>** umschlossen ist. |
| 199 | 199 | ||
| 200 | ```yuescript | 200 | ```yuescript |
| 201 | mt = {} | 201 | mt = {} |
| @@ -203,14 +203,14 @@ add = (right) => <>: mt, value: @value + right.value | |||
| 203 | mt.__add = add | 203 | mt.__add = add |
| 204 | 204 | ||
| 205 | a = <>: mt, value: 1 | 205 | a = <>: mt, value: 1 |
| 206 | -- set field with variable of the same name | 206 | -- Feld mit gleichnamiger Variable setzen |
| 207 | b = :<add>, value: 2 | 207 | b = :<add>, value: 2 |
| 208 | c = <add>: mt.__add, value: 3 | 208 | c = <add>: mt.__add, value: 3 |
| 209 | 209 | ||
| 210 | d = a + b + c | 210 | d = a + b + c |
| 211 | print d.value | 211 | print d.value |
| 212 | 212 | ||
| 213 | close _ = <close>: -> print "out of scope" | 213 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs" |
| 214 | ``` | 214 | ``` |
| 215 | <YueDisplay> | 215 | <YueDisplay> |
| 216 | 216 | ||
| @@ -220,47 +220,47 @@ add = (right) => <>: mt, value: @value + right.value | |||
| 220 | mt.__add = add | 220 | mt.__add = add |
| 221 | 221 | ||
| 222 | a = <>: mt, value: 1 | 222 | a = <>: mt, value: 1 |
| 223 | -- set field with variable of the same name | 223 | -- Feld mit gleichnamiger Variable setzen |
| 224 | b = :<add>, value: 2 | 224 | b = :<add>, value: 2 |
| 225 | c = <add>: mt.__add, value: 3 | 225 | c = <add>: mt.__add, value: 3 |
| 226 | 226 | ||
| 227 | d = a + b + c | 227 | d = a + b + c |
| 228 | print d.value | 228 | print d.value |
| 229 | 229 | ||
| 230 | close _ = <close>: -> print "out of scope" | 230 | close _ = <close>: -> print "Außerhalb des Gültigkeitsbereichs" |
| 231 | ``` | 231 | ``` |
| 232 | 232 | ||
| 233 | </YueDisplay> | 233 | </YueDisplay> |
| 234 | 234 | ||
| 235 | ### Metatable Accessing | 235 | ### Metatable-Zugriff |
| 236 | 236 | ||
| 237 | Accessing metatable with **<>** or metamethod name surrounded by **<>** or writing some expression in **<>**. | 237 | Metatable mit **<>** oder einem von **<>** umschlossenen Metamethod-Namen aufrufen oder einen Ausdruck in **<>** schreiben. |
| 238 | 238 | ||
| 239 | ```yuescript | 239 | ```yuescript |
| 240 | -- create with metatable containing field "value" | 240 | -- erstellen mit Metatable, das das Feld "value" enthält |
| 241 | tb = <"value">: 123 | 241 | tb = <"value">: 123 |
| 242 | tb.<index> = tb.<> | 242 | tb.<index> = tb.<> |
| 243 | print tb.value | 243 | print tb.value |
| 244 | 244 | ||
| 245 | tb.<> = __index: {item: "hello"} | 245 | tb.<> = __index: {item: "hallo"} |
| 246 | print tb.item | 246 | print tb.item |
| 247 | ``` | 247 | ``` |
| 248 | <YueDisplay> | 248 | <YueDisplay> |
| 249 | 249 | ||
| 250 | ```yue | 250 | ```yue |
| 251 | -- create with metatable containing field "value" | 251 | -- erstellen mit Metatable, das das Feld "value" enthält |
| 252 | tb = <"value">: 123 | 252 | tb = <"value">: 123 |
| 253 | tb.<index> = tb.<> | 253 | tb.<index> = tb.<> |
| 254 | print tb.value | 254 | print tb.value |
| 255 | tb.<> = __index: {item: "hello"} | 255 | tb.<> = __index: {item: "hallo"} |
| 256 | print tb.item | 256 | print tb.item |
| 257 | ``` | 257 | ``` |
| 258 | 258 | ||
| 259 | </YueDisplay> | 259 | </YueDisplay> |
| 260 | 260 | ||
| 261 | ### Metatable Destructure | 261 | ### Metatable-Destrukturierung |
| 262 | 262 | ||
| 263 | Destruct metatable with metamethod key surrounded by **<>**. | 263 | Destrukturiere Metatable mit Metamethoden-Schlüssel, der von **<>** umschlossen ist. |
| 264 | 264 | ||
| 265 | ```yuescript | 265 | ```yuescript |
| 266 | {item, :new, :<close>, <index>: getter} = tb | 266 | {item, :new, :<close>, <index>: getter} = tb |
| @@ -275,9 +275,9 @@ print item, new, close, getter | |||
| 275 | 275 | ||
| 276 | </YueDisplay> | 276 | </YueDisplay> |
| 277 | 277 | ||
| 278 | ## Existence | 278 | ## Existenz |
| 279 | 279 | ||
| 280 | The **?** operator can be used in a variety of contexts to check for existence. | 280 | Der Operator **?** kann in verschiedenen Kontexten verwendet werden, um die Existenz zu prüfen. |
| 281 | 281 | ||
| 282 | ```yuescript | 282 | ```yuescript |
| 283 | func?! | 283 | func?! |
| @@ -314,14 +314,14 @@ with? io.open "test.txt", "w" | |||
| 314 | 314 | ||
| 315 | ## Piping | 315 | ## Piping |
| 316 | 316 | ||
| 317 | Instead of a series of nested function calls, you can pipe values with operator **|>**. | 317 | Anstelle einer Reihe verschachtelter Funktionsaufrufe kannst du Werte mit dem Operator **|>** weiterleiten. |
| 318 | 318 | ||
| 319 | ```yuescript | 319 | ```yuescript |
| 320 | "hello" |> print | 320 | "hello" |> print |
| 321 | 1 |> print 2 -- insert pipe item as the first argument | 321 | 1 |> print 2 -- Pipe-Element als erstes Argument einfügen |
| 322 | 2 |> print 1, _, 3 -- pipe with a placeholder | 322 | 2 |> print 1, _, 3 -- Pipe mit Platzhalter |
| 323 | 323 | ||
| 324 | -- pipe expression in multiline | 324 | -- Pipe-Ausdruck über mehrere Zeilen |
| 325 | readFile "example.txt" | 325 | readFile "example.txt" |
| 326 | |> extract language, {} | 326 | |> extract language, {} |
| 327 | |> parse language | 327 | |> parse language |
| @@ -333,9 +333,9 @@ readFile "example.txt" | |||
| 333 | 333 | ||
| 334 | ```yue | 334 | ```yue |
| 335 | "hello" |> print | 335 | "hello" |> print |
| 336 | 1 |> print 2 -- insert pipe item as the first argument | 336 | 1 |> print 2 -- Pipe-Element als erstes Argument einfügen |
| 337 | 2 |> print 1, _, 3 -- pipe with a placeholder | 337 | 2 |> print 1, _, 3 -- Pipe mit Platzhalter |
| 338 | -- pipe expression in multiline | 338 | -- Pipe-Ausdruck über mehrere Zeilen |
| 339 | readFile "example.txt" | 339 | readFile "example.txt" |
| 340 | |> extract language, {} | 340 | |> extract language, {} |
| 341 | |> parse language | 341 | |> parse language |
| @@ -346,9 +346,10 @@ readFile "example.txt" | |||
| 346 | 346 | ||
| 347 | </YueDisplay> | 347 | </YueDisplay> |
| 348 | 348 | ||
| 349 | ## Nil Coalescing | 349 | ## Nil-Coalescing |
| 350 | |||
| 351 | Der Nil-Coalescing-Operator **??** gibt den Wert des linken Operanden zurück, wenn er nicht **nil** ist; andernfalls wird der rechte Operand ausgewertet und sein Ergebnis zurückgegeben. Der **??**-Operator wertet seinen rechten Operanden nicht aus, wenn der linke Operand nicht nil ergibt. | ||
| 350 | 352 | ||
| 351 | The nil-coalescing operator **??** returns the value of its left-hand operand if it isn't **nil**; otherwise, it evaluates the right-hand operand and returns its result. The **??** operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-nil. | ||
| 352 | ```yuescript | 353 | ```yuescript |
| 353 | local a, b, c, d | 354 | local a, b, c, d |
| 354 | a = b ?? c ?? d | 355 | a = b ?? c ?? d |
| @@ -367,31 +368,31 @@ a ??= false | |||
| 367 | 368 | ||
| 368 | </YueDisplay> | 369 | </YueDisplay> |
| 369 | 370 | ||
| 370 | ## Implicit Object | 371 | ## Implizites Objekt |
| 371 | 372 | ||
| 372 | You can write a list of implicit structures that starts with the symbol **\*** or **-** inside a table block. If you are creating implicit object, the fields of the object must be with the same indent. | 373 | Du kannst innerhalb eines Tabellenblocks eine Liste impliziter Strukturen schreiben, die mit dem Symbol **\*** oder **-** beginnt. Beim Erstellen eines impliziten Objekts müssen die Felder des Objekts dieselbe Einrückung haben. |
| 373 | 374 | ||
| 374 | ```yuescript | 375 | ```yuescript |
| 375 | -- assignment with implicit object | 376 | -- Zuweisung mit implizitem Objekt |
| 376 | list = | 377 | list = |
| 377 | * 1 | 378 | * 1 |
| 378 | * 2 | 379 | * 2 |
| 379 | * 3 | 380 | * 3 |
| 380 | 381 | ||
| 381 | -- function call with implicit object | 382 | -- Funktionsaufruf mit implizitem Objekt |
| 382 | func | 383 | func |
| 383 | * 1 | 384 | * 1 |
| 384 | * 2 | 385 | * 2 |
| 385 | * 3 | 386 | * 3 |
| 386 | 387 | ||
| 387 | -- return with implicit object | 388 | -- Rückgabe mit implizitem Objekt |
| 388 | f = -> | 389 | f = -> |
| 389 | return | 390 | return |
| 390 | * 1 | 391 | * 1 |
| 391 | * 2 | 392 | * 2 |
| 392 | * 3 | 393 | * 3 |
| 393 | 394 | ||
| 394 | -- table with implicit object | 395 | -- Tabelle mit implizitem Objekt |
| 395 | tb = | 396 | tb = |
| 396 | name: "abc" | 397 | name: "abc" |
| 397 | 398 | ||
| @@ -416,26 +417,26 @@ tb = | |||
| 416 | <YueDisplay> | 417 | <YueDisplay> |
| 417 | 418 | ||
| 418 | ```yue | 419 | ```yue |
| 419 | -- assignment with implicit object | 420 | -- Zuweisung mit implizitem Objekt |
| 420 | list = | 421 | list = |
| 421 | * 1 | 422 | * 1 |
| 422 | * 2 | 423 | * 2 |
| 423 | * 3 | 424 | * 3 |
| 424 | 425 | ||
| 425 | -- function call with implicit object | 426 | -- Funktionsaufruf mit implizitem Objekt |
| 426 | func | 427 | func |
| 427 | * 1 | 428 | * 1 |
| 428 | * 2 | 429 | * 2 |
| 429 | * 3 | 430 | * 3 |
| 430 | 431 | ||
| 431 | -- return with implicit object | 432 | -- Rückgabe mit implizitem Objekt |
| 432 | f = -> | 433 | f = -> |
| 433 | return | 434 | return |
| 434 | * 1 | 435 | * 1 |
| 435 | * 2 | 436 | * 2 |
| 436 | * 3 | 437 | * 3 |
| 437 | 438 | ||
| 438 | -- table with implicit object | 439 | -- Tabelle mit implizitem Objekt |
| 439 | tb = | 440 | tb = |
| 440 | name: "abc" | 441 | name: "abc" |
| 441 | 442 | ||
diff --git a/doc/docs/de/doc/language-basics/whitespace.md b/doc/docs/de/doc/language-basics/whitespace.md index d742a2b..9d5889d 100644 --- a/doc/docs/de/doc/language-basics/whitespace.md +++ b/doc/docs/de/doc/language-basics/whitespace.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Whitespace | 1 | # Leerraum |
| 2 | 2 | ||
| 3 | YueScript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. | 3 | YueScript ist eine whitespace-sensible Sprache. Du musst bestimmte Code-Blöcke mit derselben Einrückung (Leerzeichen **' '** oder Tab **'\t'**) schreiben, z. B. Funktionskörper, Wertelisten und Kontrollblöcke. Ausdrücke mit unterschiedlichem Leerraum können unterschiedliche Bedeutungen haben. Ein Tab wird wie 4 Leerzeichen behandelt, aber es ist besser, Leerzeichen und Tabs nicht zu mischen. |
| 4 | 4 | ||
| 5 | ## Statement Separator | 5 | ## Anweisungs-Trenner |
| 6 | 6 | ||
| 7 | A statement normally ends at a line break. You can also use a semicolon `;` to explicitly terminate a statement, which allows writing multiple statements on the same line: | 7 | Eine Anweisung endet normalerweise an einem Zeilenumbruch. Du kannst auch ein Semikolon `;` verwenden, um eine Anweisung explizit zu beenden, wodurch mehrere Anweisungen in einer Zeile möglich sind: |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| @@ -17,9 +17,9 @@ a = 1; b = 2; print a + b | |||
| 17 | 17 | ||
| 18 | </YueDisplay> | 18 | </YueDisplay> |
| 19 | 19 | ||
| 20 | ## Multiline Chaining | 20 | ## Mehrzeiliges Chaining |
| 21 | 21 | ||
| 22 | You can write multi-line chaining function calls with a same indent. | 22 | Du kannst mehrzeilige, verkettete Funktionsaufrufe mit derselben Einrückung schreiben. |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | Rx.Observable | 25 | Rx.Observable |
diff --git a/doc/docs/de/doc/objects/object-oriented-programming.md b/doc/docs/de/doc/objects/object-oriented-programming.md index 6a8559e..1c116a3 100644 --- a/doc/docs/de/doc/objects/object-oriented-programming.md +++ b/doc/docs/de/doc/objects/object-oriented-programming.md | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | # Object Oriented Programming | 1 | # Objektorientierte Programmierung |
| 2 | 2 | ||
| 3 | In these examples, the generated Lua code may appear overwhelming. It is best to focus on the meaning of the YueScript code at first, then look into the Lua code if you wish to know the implementation details. | 3 | In diesen Beispielen kann der generierte Lua-Code überwältigend wirken. Am besten konzentrierst du dich zunächst auf die Bedeutung des YueScript-Codes und schaust dir den Lua-Code nur an, wenn du die Implementierungsdetails wissen möchtest. |
| 4 | 4 | ||
| 5 | A simple class: | 5 | Eine einfache Klasse: |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | class Inventory | 8 | class Inventory |
| @@ -31,36 +31,36 @@ class Inventory | |||
| 31 | 31 | ||
| 32 | </YueDisplay> | 32 | </YueDisplay> |
| 33 | 33 | ||
| 34 | A class is declared with a class statement followed by a table-like declaration where all of the methods and properties are listed. | 34 | Eine Klasse wird mit einem `class`-Statement deklariert, gefolgt von einer tabellenähnlichen Deklaration mit allen Methoden und Eigenschaften. |
| 35 | 35 | ||
| 36 | The new property is special in that it will become the constructor. | 36 | Die Eigenschaft `new` ist besonders, da sie zum Konstruktor wird. |
| 37 | 37 | ||
| 38 | Notice how all the methods in the class use the fat arrow function syntax. When calling methods on a instance, the instance itself is sent in as the first argument. The fat arrow handles the creation of a self argument. | 38 | Beachte, dass alle Methoden in der Klasse die Fat-Arrow-Syntax verwenden. Beim Aufruf von Methoden auf einer Instanz wird die Instanz selbst als erstes Argument übergeben. Der Fat-Arrow übernimmt die Erstellung des `self`-Arguments. |
| 39 | 39 | ||
| 40 | The @ prefix on a variable name is shorthand for self.. @items becomes self.items. | 40 | Das `@`-Präfix ist Kurzform für `self.`. `@items` wird zu `self.items`. |
| 41 | 41 | ||
| 42 | Creating an instance of the class is done by calling the name of the class as a function. | 42 | Eine Instanz der Klasse wird erstellt, indem man den Klassennamen wie eine Funktion aufruft. |
| 43 | 43 | ||
| 44 | ```yuescript | 44 | ```yuescript |
| 45 | inv = Inventory! | 45 | inv = Inventory! |
| 46 | inv\add_item "t-shirt" | 46 | inv\add_item "T-Shirt" |
| 47 | inv\add_item "pants" | 47 | inv\add_item "Hose" |
| 48 | ``` | 48 | ``` |
| 49 | <YueDisplay> | 49 | <YueDisplay> |
| 50 | 50 | ||
| 51 | ```yue | 51 | ```yue |
| 52 | inv = Inventory! | 52 | inv = Inventory! |
| 53 | inv\add_item "t-shirt" | 53 | inv\add_item "T-Shirt" |
| 54 | inv\add_item "pants" | 54 | inv\add_item "Hose" |
| 55 | ``` | 55 | ``` |
| 56 | 56 | ||
| 57 | </YueDisplay> | 57 | </YueDisplay> |
| 58 | 58 | ||
| 59 | Because the instance of the class needs to be sent to the methods when they are called, the \ operator is used. | 59 | Da die Instanz bei Methodenaufrufen an die Methoden übergeben werden muss, wird der `\`-Operator verwendet. |
| 60 | 60 | ||
| 61 | All properties of a class are shared among the instances. This is fine for functions, but for other types of objects, undesired results may occur. | 61 | Alle Eigenschaften einer Klasse werden von allen Instanzen gemeinsam genutzt. Für Funktionen ist das ok, aber bei anderen Objekten kann das zu unerwünschten Ergebnissen führen. |
| 62 | 62 | ||
| 63 | Consider the example below, the clothes property is shared amongst all instances, so modifications to it in one instance will show up in another: | 63 | Im folgenden Beispiel wird die Eigenschaft `clothes` von allen Instanzen geteilt, sodass Änderungen in einer Instanz in einer anderen sichtbar werden: |
| 64 | 64 | ||
| 65 | ```yuescript | 65 | ```yuescript |
| 66 | class Person | 66 | class Person |
| @@ -71,10 +71,10 @@ class Person | |||
| 71 | a = Person! | 71 | a = Person! |
| 72 | b = Person! | 72 | b = Person! |
| 73 | 73 | ||
| 74 | a\give_item "pants" | 74 | a\give_item "Hose" |
| 75 | b\give_item "shirt" | 75 | b\give_item "Hemd" |
| 76 | 76 | ||
| 77 | -- will print both pants and shirt | 77 | -- gibt sowohl Hose als auch Hemd aus |
| 78 | print item for item in *a.clothes | 78 | print item for item in *a.clothes |
| 79 | ``` | 79 | ``` |
| 80 | <YueDisplay> | 80 | <YueDisplay> |
| @@ -88,16 +88,16 @@ class Person | |||
| 88 | a = Person! | 88 | a = Person! |
| 89 | b = Person! | 89 | b = Person! |
| 90 | 90 | ||
| 91 | a\give_item "pants" | 91 | a\give_item "Hose" |
| 92 | b\give_item "shirt" | 92 | b\give_item "Hemd" |
| 93 | 93 | ||
| 94 | -- will print both pants and shirt | 94 | -- gibt sowohl Hose als auch Hemd aus |
| 95 | print item for item in *a.clothes | 95 | print item for item in *a.clothes |
| 96 | ``` | 96 | ``` |
| 97 | 97 | ||
| 98 | </YueDisplay> | 98 | </YueDisplay> |
| 99 | 99 | ||
| 100 | The proper way to avoid this problem is to create the mutable state of the object in the constructor: | 100 | Der richtige Weg, das zu vermeiden, ist, den veränderlichen Zustand im Konstruktor zu erstellen: |
| 101 | 101 | ||
| 102 | ```yuescript | 102 | ```yuescript |
| 103 | class Person | 103 | class Person |
| @@ -114,15 +114,15 @@ class Person | |||
| 114 | 114 | ||
| 115 | </YueDisplay> | 115 | </YueDisplay> |
| 116 | 116 | ||
| 117 | ## Inheritance | 117 | ## Vererbung |
| 118 | 118 | ||
| 119 | The extends keyword can be used in a class declaration to inherit the properties and methods from another class. | 119 | Das Schlüsselwort `extends` kann in einer Klassendeklaration verwendet werden, um Eigenschaften und Methoden von einer anderen Klasse zu erben. |
| 120 | 120 | ||
| 121 | ```yuescript | 121 | ```yuescript |
| 122 | class BackPack extends Inventory | 122 | class BackPack extends Inventory |
| 123 | size: 10 | 123 | size: 10 |
| 124 | add_item: (name) => | 124 | add_item: (name) => |
| 125 | if #@items > size then error "backpack is full" | 125 | if #@items > size then error "Rucksack ist voll" |
| 126 | super name | 126 | super name |
| 127 | ``` | 127 | ``` |
| 128 | <YueDisplay> | 128 | <YueDisplay> |
| @@ -131,24 +131,24 @@ class BackPack extends Inventory | |||
| 131 | class BackPack extends Inventory | 131 | class BackPack extends Inventory |
| 132 | size: 10 | 132 | size: 10 |
| 133 | add_item: (name) => | 133 | add_item: (name) => |
| 134 | if #@items > size then error "backpack is full" | 134 | if #@items > size then error "Rucksack ist voll" |
| 135 | super name | 135 | super name |
| 136 | ``` | 136 | ``` |
| 137 | 137 | ||
| 138 | </YueDisplay> | 138 | </YueDisplay> |
| 139 | 139 | ||
| 140 | Here we extend our Inventory class, and limit the amount of items it can carry. | 140 | Hier erweitern wir unsere `Inventory`-Klasse und begrenzen die Anzahl der Elemente. |
| 141 | 141 | ||
| 142 | In this example, we don't define a constructor on the subclass, so the parent class' constructor is called when we make a new instance. If we did define a constructor then we can use the super method to call the parent constructor. | 142 | In diesem Beispiel definieren wir keinen Konstruktor in der Subklasse, daher wird der Konstruktor der Elternklasse beim Erstellen einer neuen Instanz aufgerufen. Definieren wir einen Konstruktor, können wir mit `super` den Elternkonstruktor aufrufen. |
| 143 | 143 | ||
| 144 | Whenever a class inherits from another, it sends a message to the parent class by calling the method __inherited on the parent class if it exists. The function receives two arguments, the class that is being inherited and the child class. | 144 | Wenn eine Klasse von einer anderen erbt, sendet sie eine Nachricht an die Elternklasse, indem die Methode `__inherited` der Elternklasse aufgerufen wird, falls vorhanden. Die Funktion erhält zwei Argumente: die Klasse, die vererbt wird, und die Kindklasse. |
| 145 | 145 | ||
| 146 | ```yuescript | 146 | ```yuescript |
| 147 | class Shelf | 147 | class Shelf |
| 148 | @__inherited: (child) => | 148 | @__inherited: (child) => |
| 149 | print @__name, "was inherited by", child.__name | 149 | print @__name, "wurde vererbt von", child.__name |
| 150 | 150 | ||
| 151 | -- will print: Shelf was inherited by Cupboard | 151 | -- gibt aus: Shelf wurde von Cupboard geerbt |
| 152 | class Cupboard extends Shelf | 152 | class Cupboard extends Shelf |
| 153 | ``` | 153 | ``` |
| 154 | <YueDisplay> | 154 | <YueDisplay> |
| @@ -156,9 +156,9 @@ class Cupboard extends Shelf | |||
| 156 | ```yue | 156 | ```yue |
| 157 | class Shelf | 157 | class Shelf |
| 158 | @__inherited: (child) => | 158 | @__inherited: (child) => |
| 159 | print @__name, "was inherited by", child.__name | 159 | print @__name, "wurde vererbt von", child.__name |
| 160 | 160 | ||
| 161 | -- will print: Shelf was inherited by Cupboard | 161 | -- gibt aus: Shelf wurde von Cupboard geerbt |
| 162 | class Cupboard extends Shelf | 162 | class Cupboard extends Shelf |
| 163 | ``` | 163 | ``` |
| 164 | 164 | ||
| @@ -166,27 +166,27 @@ class Cupboard extends Shelf | |||
| 166 | 166 | ||
| 167 | ## Super | 167 | ## Super |
| 168 | 168 | ||
| 169 | **super** is a special keyword that can be used in two different ways: It can be treated as an object, or it can be called like a function. It only has special functionality when inside a class. | 169 | **super** ist ein spezielles Schlüsselwort, das auf zwei Arten verwendet werden kann: als Objekt oder als Funktionsaufruf. Es hat besondere Funktionalität nur innerhalb einer Klasse. |
| 170 | 170 | ||
| 171 | When called as a function, it will call the function of the same name in the parent class. The current self will automatically be passed as the first argument. (As seen in the inheritance example above) | 171 | Wenn es als Funktion aufgerufen wird, ruft es die gleichnamige Funktion in der Elternklasse auf. `self` wird automatisch als erstes Argument übergeben (wie im Vererbungsbeispiel oben). |
| 172 | 172 | ||
| 173 | When super is used as a normal value, it is a reference to the parent class object. | 173 | Wenn `super` als normaler Wert verwendet wird, ist es eine Referenz auf das Objekt der Elternklasse. |
| 174 | 174 | ||
| 175 | It can be accessed like any of object in order to retrieve values in the parent class that might have been shadowed by the child class. | 175 | Du kannst es wie jedes andere Objekt verwenden, um Werte der Elternklasse zu lesen, die von der Kindklasse überschattet wurden. |
| 176 | 176 | ||
| 177 | When the \ calling operator is used with super, self is inserted as the first argument instead of the value of super itself. When using . to retrieve a function, the raw function is returned. | 177 | Wenn der `\`-Aufrufoperator mit `super` verwendet wird, wird `self` als erstes Argument eingefügt statt des Wertes von `super`. Wenn man `.` zum Abrufen einer Funktion verwendet, wird die rohe Funktion zurückgegeben. |
| 178 | 178 | ||
| 179 | A few examples of using super in different ways: | 179 | Ein paar Beispiele für `super` in unterschiedlichen Formen: |
| 180 | 180 | ||
| 181 | ```yuescript | 181 | ```yuescript |
| 182 | class MyClass extends ParentClass | 182 | class MyClass extends ParentClass |
| 183 | a_method: => | 183 | a_method: => |
| 184 | -- the following have the same effect: | 184 | -- Folgendes hat dieselbe Wirkung: |
| 185 | super "hello", "world" | 185 | super "hallo", "Welt" |
| 186 | super\a_method "hello", "world" | 186 | super\a_method "hallo", "Welt" |
| 187 | super.a_method self, "hello", "world" | 187 | super.a_method self, "hallo", "Welt" |
| 188 | 188 | ||
| 189 | -- super as a value is equal to the parent class: | 189 | -- super als Wert entspricht der Elternklasse: |
| 190 | assert super == ParentClass | 190 | assert super == ParentClass |
| 191 | ``` | 191 | ``` |
| 192 | <YueDisplay> | 192 | <YueDisplay> |
| @@ -194,28 +194,28 @@ class MyClass extends ParentClass | |||
| 194 | ```yue | 194 | ```yue |
| 195 | class MyClass extends ParentClass | 195 | class MyClass extends ParentClass |
| 196 | a_method: => | 196 | a_method: => |
| 197 | -- the following have the same effect: | 197 | -- Folgendes hat dieselbe Wirkung: |
| 198 | super "hello", "world" | 198 | super "hallo", "Welt" |
| 199 | super\a_method "hello", "world" | 199 | super\a_method "hallo", "Welt" |
| 200 | super.a_method self, "hello", "world" | 200 | super.a_method self, "hallo", "Welt" |
| 201 | 201 | ||
| 202 | -- super as a value is equal to the parent class: | 202 | -- super als Wert entspricht der Elternklasse: |
| 203 | assert super == ParentClass | 203 | assert super == ParentClass |
| 204 | ``` | 204 | ``` |
| 205 | 205 | ||
| 206 | </YueDisplay> | 206 | </YueDisplay> |
| 207 | 207 | ||
| 208 | **super** can also be used on left side of a Function Stub. The only major difference is that instead of the resulting function being bound to the value of super, it is bound to self. | 208 | **super** kann auch links einer Funktions-Stub verwendet werden. Der einzige große Unterschied ist, dass die resultierende Funktion statt an `super` an `self` gebunden wird. |
| 209 | 209 | ||
| 210 | ## Types | 210 | ## Typen |
| 211 | 211 | ||
| 212 | Every instance of a class carries its type with it. This is stored in the special __class property. This property holds the class object. The class object is what we call to build a new instance. We can also index the class object to retrieve class methods and properties. | 212 | Jede Instanz einer Klasse trägt ihren Typ in sich. Dieser wird in der speziellen Eigenschaft `__class` gespeichert. Diese Eigenschaft enthält das Klassenobjekt. Das Klassenobjekt wird aufgerufen, um eine neue Instanz zu erstellen. Wir können das Klassenobjekt auch indizieren, um Klassenmethoden und Eigenschaften abzurufen. |
| 213 | 213 | ||
| 214 | ```yuescript | 214 | ```yuescript |
| 215 | b = BackPack! | 215 | b = BackPack! |
| 216 | assert b.__class == BackPack | 216 | assert b.__class == BackPack |
| 217 | 217 | ||
| 218 | print BackPack.size -- prints 10 | 218 | print BackPack.size -- gibt 10 aus |
| 219 | ``` | 219 | ``` |
| 220 | <YueDisplay> | 220 | <YueDisplay> |
| 221 | 221 | ||
| @@ -223,70 +223,70 @@ print BackPack.size -- prints 10 | |||
| 223 | b = BackPack! | 223 | b = BackPack! |
| 224 | assert b.__class == BackPack | 224 | assert b.__class == BackPack |
| 225 | 225 | ||
| 226 | print BackPack.size -- prints 10 | 226 | print BackPack.size -- gibt 10 aus |
| 227 | ``` | 227 | ``` |
| 228 | 228 | ||
| 229 | </YueDisplay> | 229 | </YueDisplay> |
| 230 | 230 | ||
| 231 | ## Class Objects | 231 | ## Klassenobjekte |
| 232 | 232 | ||
| 233 | The class object is what we create when we use a class statement. The class object is stored in a variable of the same name of the class. | 233 | Das Klassenobjekt entsteht, wenn wir ein `class`-Statement verwenden. Es wird in einer Variablen mit dem Klassennamen gespeichert. |
| 234 | 234 | ||
| 235 | The class object can be called like a function in order to create new instances. That's how we created instances of classes in the examples above. | 235 | Das Klassenobjekt kann wie eine Funktion aufgerufen werden, um neue Instanzen zu erstellen. So haben wir die Instanzen in den Beispielen oben erstellt. |
| 236 | 236 | ||
| 237 | A class is made up of two tables. The class table itself, and the base table. The base is used as the metatable for all the instances. All properties listed in the class declaration are placed in the base. | 237 | Eine Klasse besteht aus zwei Tabellen: der Klassentabelle selbst und der Basistabelle. Die Basis wird als Metatable für alle Instanzen verwendet. Alle in der Klassendeklaration aufgeführten Eigenschaften werden in der Basis platziert. |
| 238 | 238 | ||
| 239 | The class object's metatable reads properties from the base if they don't exist in the class object. This means we can access functions and properties directly from the class. | 239 | Das Metatable des Klassenobjekts liest Eigenschaften aus der Basis, wenn sie im Klassenobjekt nicht existieren. Das bedeutet, dass wir Funktionen und Eigenschaften direkt von der Klasse aus aufrufen können. |
| 240 | 240 | ||
| 241 | It is important to note that assigning to the class object does not assign into the base, so it's not a valid way to add new methods to instances. Instead the base must explicitly be changed. See the __base field below. | 241 | Wichtig: Zuweisungen an das Klassenobjekt schreiben nicht in die Basis. Das ist keine gültige Methode, um neue Methoden zu Instanzen hinzuzufügen. Stattdessen muss die Basis explizit geändert werden. Siehe das Feld `__base` unten. |
| 242 | 242 | ||
| 243 | The class object has a couple special properties: | 243 | Das Klassenobjekt hat einige spezielle Eigenschaften: |
| 244 | 244 | ||
| 245 | The name of the class as when it was declared is stored as a string in the __name field of the class object. | 245 | Der Name der Klasse, wie sie deklariert wurde, wird im Feld `__name` gespeichert. |
| 246 | 246 | ||
| 247 | ```yuescript | 247 | ```yuescript |
| 248 | print BackPack.__name -- prints Backpack | 248 | print BackPack.__name -- gibt Backpack aus |
| 249 | ``` | 249 | ``` |
| 250 | <YueDisplay> | 250 | <YueDisplay> |
| 251 | 251 | ||
| 252 | ```yue | 252 | ```yue |
| 253 | print BackPack.__name -- prints Backpack | 253 | print BackPack.__name -- gibt Backpack aus |
| 254 | ``` | 254 | ``` |
| 255 | 255 | ||
| 256 | </YueDisplay> | 256 | </YueDisplay> |
| 257 | 257 | ||
| 258 | The base object is stored in __base. We can modify this table to add functionality to instances that have already been created and ones that are yet to be created. | 258 | Die Basistabelle ist in `__base` gespeichert. Du kannst diese Tabelle ändern, um Instanzen Funktionalität hinzuzufügen, die bereits existieren oder noch erstellt werden. |
| 259 | 259 | ||
| 260 | If the class extends from anything, the parent class object is stored in __parent. | 260 | Wenn die Klasse von etwas erbt, ist das Elternklassenobjekt in `__parent` gespeichert. |
| 261 | 261 | ||
| 262 | ## Class Variables | 262 | ## Klassenvariablen |
| 263 | 263 | ||
| 264 | We can create variables directly in the class object instead of in the base by using @ in the front of the property name in a class declaration. | 264 | Du kannst Variablen direkt im Klassenobjekt statt in der Basis erstellen, indem du in der Klassendeklaration `@` vor den Eigenschaftsnamen setzt. |
| 265 | 265 | ||
| 266 | ```yuescript | 266 | ```yuescript |
| 267 | class Things | 267 | class Things |
| 268 | @some_func: => print "Hello from", @__name | 268 | @some_func: => print "Hallo von", @__name |
| 269 | 269 | ||
| 270 | Things\some_func! | 270 | Things\some_func! |
| 271 | 271 | ||
| 272 | -- class variables not visible in instances | 272 | -- Klassenvariablen in Instanzen nicht sichtbar |
| 273 | assert Things().some_func == nil | 273 | assert Things().some_func == nil |
| 274 | ``` | 274 | ``` |
| 275 | <YueDisplay> | 275 | <YueDisplay> |
| 276 | 276 | ||
| 277 | ```yue | 277 | ```yue |
| 278 | class Things | 278 | class Things |
| 279 | @some_func: => print "Hello from", @__name | 279 | @some_func: => print "Hallo von", @__name |
| 280 | 280 | ||
| 281 | Things\some_func! | 281 | Things\some_func! |
| 282 | 282 | ||
| 283 | -- class variables not visible in instances | 283 | -- Klassenvariablen in Instanzen nicht sichtbar |
| 284 | assert Things().some_func == nil | 284 | assert Things().some_func == nil |
| 285 | ``` | 285 | ``` |
| 286 | 286 | ||
| 287 | </YueDisplay> | 287 | </YueDisplay> |
| 288 | 288 | ||
| 289 | In expressions, we can use @@ to access a value that is stored in the __class of self. Thus, @@hello is shorthand for self.__class.hello. | 289 | In Ausdrücken können wir `@@` verwenden, um auf einen Wert zuzugreifen, der in `self.__class` gespeichert ist. `@@hello` ist also eine Kurzform für `self.__class.hello`. |
| 290 | 290 | ||
| 291 | ```yuescript | 291 | ```yuescript |
| 292 | class Counter | 292 | class Counter |
| @@ -298,7 +298,7 @@ class Counter | |||
| 298 | Counter! | 298 | Counter! |
| 299 | Counter! | 299 | Counter! |
| 300 | 300 | ||
| 301 | print Counter.count -- prints 2 | 301 | print Counter.count -- gibt 2 aus |
| 302 | ``` | 302 | ``` |
| 303 | <YueDisplay> | 303 | <YueDisplay> |
| 304 | 304 | ||
| @@ -312,12 +312,12 @@ class Counter | |||
| 312 | Counter! | 312 | Counter! |
| 313 | Counter! | 313 | Counter! |
| 314 | 314 | ||
| 315 | print Counter.count -- prints 2 | 315 | print Counter.count -- gibt 2 aus |
| 316 | ``` | 316 | ``` |
| 317 | 317 | ||
| 318 | </YueDisplay> | 318 | </YueDisplay> |
| 319 | 319 | ||
| 320 | The calling semantics of @@ are similar to @. Calling a @@ name will pass the class in as the first argument using Lua's colon syntax. | 320 | Die Aufrufsemantik von `@@` ist ähnlich wie bei `@`. Wenn du einen `@@`-Namen aufrufst, wird die Klasse als erstes Argument übergeben (Lua-`:`-Syntax). |
| 321 | 321 | ||
| 322 | ```yuescript | 322 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 323 | @@hello 1,2,3,4 |
| @@ -330,28 +330,28 @@ The calling semantics of @@ are similar to @. Calling a @@ name will pass the cl | |||
| 330 | 330 | ||
| 331 | </YueDisplay> | 331 | </YueDisplay> |
| 332 | 332 | ||
| 333 | ## Class Declaration Statements | 333 | ## Klassendeklarations-Statements |
| 334 | 334 | ||
| 335 | In the body of a class declaration, we can have normal expressions in addition to key/value pairs. In this context, self is equal to the class object. | 335 | Im Rumpf einer Klassendeklaration können wir normale Ausdrücke zusätzlich zu Schlüssel/Wert-Paaren haben. In diesem Kontext ist `self` gleich dem Klassenobjekt. |
| 336 | 336 | ||
| 337 | Here is an alternative way to create a class variable compared to what's described above: | 337 | Hier ist eine alternative Möglichkeit, eine Klassenvariable zu erstellen: |
| 338 | 338 | ||
| 339 | ```yuescript | 339 | ```yuescript |
| 340 | class Things | 340 | class Things |
| 341 | @class_var = "hello world" | 341 | @class_var = "Hallo Welt" |
| 342 | ``` | 342 | ``` |
| 343 | <YueDisplay> | 343 | <YueDisplay> |
| 344 | 344 | ||
| 345 | ```yue | 345 | ```yue |
| 346 | class Things | 346 | class Things |
| 347 | @class_var = "hello world" | 347 | @class_var = "Hallo Welt" |
| 348 | ``` | 348 | ``` |
| 349 | 349 | ||
| 350 | </YueDisplay> | 350 | </YueDisplay> |
| 351 | 351 | ||
| 352 | These expressions are executed after all the properties have been added to the base. | 352 | Diese Ausdrücke werden ausgeführt, nachdem alle Eigenschaften zur Basis hinzugefügt wurden. |
| 353 | 353 | ||
| 354 | All variables declared in the body of the class are local to the classes properties. This is convenient for placing private values or helper functions that only the class methods can access: | 354 | Alle Variablen, die im Klassenkörper deklariert werden, sind lokal zu den Klasseneigenschaften. Das ist praktisch, um private Werte oder Hilfsfunktionen zu platzieren, auf die nur die Klassenmethoden zugreifen können: |
| 355 | 355 | ||
| 356 | ```yuescript | 356 | ```yuescript |
| 357 | class MoreThings | 357 | class MoreThings |
| @@ -359,7 +359,7 @@ class MoreThings | |||
| 359 | log = (msg) -> print "LOG:", msg | 359 | log = (msg) -> print "LOG:", msg |
| 360 | 360 | ||
| 361 | some_method: => | 361 | some_method: => |
| 362 | log "hello world: " .. secret | 362 | log "Hallo Welt: " .. secret |
| 363 | ``` | 363 | ``` |
| 364 | <YueDisplay> | 364 | <YueDisplay> |
| 365 | 365 | ||
| @@ -369,16 +369,16 @@ class MoreThings | |||
| 369 | log = (msg) -> print "LOG:", msg | 369 | log = (msg) -> print "LOG:", msg |
| 370 | 370 | ||
| 371 | some_method: => | 371 | some_method: => |
| 372 | log "hello world: " .. secret | 372 | log "Hallo Welt: " .. secret |
| 373 | ``` | 373 | ``` |
| 374 | 374 | ||
| 375 | </YueDisplay> | 375 | </YueDisplay> |
| 376 | 376 | ||
| 377 | ## @ and @@ Values | 377 | ## @- und @@-Werte |
| 378 | 378 | ||
| 379 | When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.__class. | 379 | Wenn `@` und `@@` vor einem Namen stehen, repräsentieren sie den Namen in `self` bzw. `self.__class`. |
| 380 | 380 | ||
| 381 | If they are used all by themselves, they are aliases for self and self.__class. | 381 | Wenn sie alleine verwendet werden, sind sie Aliase für `self` und `self.__class`. |
| 382 | 382 | ||
| 383 | ```yuescript | 383 | ```yuescript |
| 384 | assert @ == self | 384 | assert @ == self |
| @@ -393,7 +393,7 @@ assert @@ == self.__class | |||
| 393 | 393 | ||
| 394 | </YueDisplay> | 394 | </YueDisplay> |
| 395 | 395 | ||
| 396 | For example, a quick way to create a new instance of the same class from an instance method using @@: | 396 | Zum Beispiel kannst du mit `@@` in einer Instanzmethode schnell eine neue Instanz derselben Klasse erzeugen: |
| 397 | 397 | ||
| 398 | ```yuescript | 398 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 399 | some_instance_method = (...) => @@ ... |
| @@ -406,15 +406,15 @@ some_instance_method = (...) => @@ ... | |||
| 406 | 406 | ||
| 407 | </YueDisplay> | 407 | </YueDisplay> |
| 408 | 408 | ||
| 409 | ## Constructor Property Promotion | 409 | ## Konstruktor-Property-Promotion |
| 410 | 410 | ||
| 411 | To reduce the boilerplate code for definition of simple value objects. You can write a simple class like: | 411 | Um Boilerplate beim Definieren einfacher Value-Objekte zu reduzieren, kannst du eine Klasse so schreiben: |
| 412 | 412 | ||
| 413 | ```yuescript | 413 | ```yuescript |
| 414 | class Something | 414 | class Something |
| 415 | new: (@foo, @bar, @@biz, @@baz) => | 415 | new: (@foo, @bar, @@biz, @@baz) => |
| 416 | 416 | ||
| 417 | -- Which is short for | 417 | -- Kurzform für |
| 418 | 418 | ||
| 419 | class Something | 419 | class Something |
| 420 | new: (foo, bar, biz, baz) => | 420 | new: (foo, bar, biz, baz) => |
| @@ -429,7 +429,7 @@ class Something | |||
| 429 | class Something | 429 | class Something |
| 430 | new: (@foo, @bar, @@biz, @@baz) => | 430 | new: (@foo, @bar, @@biz, @@baz) => |
| 431 | 431 | ||
| 432 | -- Which is short for | 432 | -- Kurzform für |
| 433 | 433 | ||
| 434 | class Something | 434 | class Something |
| 435 | new: (foo, bar, biz, baz) => | 435 | new: (foo, bar, biz, baz) => |
| @@ -441,7 +441,7 @@ class Something | |||
| 441 | 441 | ||
| 442 | </YueDisplay> | 442 | </YueDisplay> |
| 443 | 443 | ||
| 444 | You can also use this syntax for a common function to initialize a object's fields. | 444 | Du kannst diese Syntax auch für eine gemeinsame Funktion verwenden, um Objektfelder zu initialisieren. |
| 445 | 445 | ||
| 446 | ```yuescript | 446 | ```yuescript |
| 447 | new = (@fieldA, @fieldB) => @ | 447 | new = (@fieldA, @fieldB) => @ |
| @@ -458,9 +458,9 @@ print obj | |||
| 458 | 458 | ||
| 459 | </YueDisplay> | 459 | </YueDisplay> |
| 460 | 460 | ||
| 461 | ## Class Expressions | 461 | ## Klassenausdrücke |
| 462 | 462 | ||
| 463 | The class syntax can also be used as an expression which can be assigned to a variable or explicitly returned. | 463 | Die `class`-Syntax kann auch als Ausdruck verwendet werden, der einer Variable zugewiesen oder explizit zurückgegeben wird. |
| 464 | 464 | ||
| 465 | ```yuescript | 465 | ```yuescript |
| 466 | x = class Bucket | 466 | x = class Bucket |
| @@ -477,9 +477,9 @@ x = class Bucket | |||
| 477 | 477 | ||
| 478 | </YueDisplay> | 478 | </YueDisplay> |
| 479 | 479 | ||
| 480 | ## Anonymous classes | 480 | ## Anonyme Klassen |
| 481 | 481 | ||
| 482 | The name can be left out when declaring a class. The __name attribute will be nil, unless the class expression is in an assignment. The name on the left hand side of the assignment is used instead of nil. | 482 | Der Name kann beim Deklarieren einer Klasse weggelassen werden. Das `__name`-Attribut ist dann `nil`, es sei denn, der Klassenausdruck steht in einer Zuweisung. In diesem Fall wird der Name auf der linken Seite statt `nil` verwendet. |
| 483 | 483 | ||
| 484 | ```yuescript | 484 | ```yuescript |
| 485 | BigBucket = class extends Bucket | 485 | BigBucket = class extends Bucket |
| @@ -498,7 +498,7 @@ assert Bucket.__name == "BigBucket" | |||
| 498 | 498 | ||
| 499 | </YueDisplay> | 499 | </YueDisplay> |
| 500 | 500 | ||
| 501 | You can even leave off the body, meaning you can write a blank anonymous class like this: | 501 | Du kannst sogar den Körper weglassen und eine leere anonyme Klasse schreiben: |
| 502 | 502 | ||
| 503 | ```yuescript | 503 | ```yuescript |
| 504 | x = class | 504 | x = class |
| @@ -513,7 +513,7 @@ x = class | |||
| 513 | 513 | ||
| 514 | ## Class Mixing | 514 | ## Class Mixing |
| 515 | 515 | ||
| 516 | You can do mixing with keyword `using` to copy functions from either a plain table or a predefined class object into your new class. When doing mixing with a plain table, you can override the class indexing function (metamethod `__index`) to your customized implementation. When doing mixing with an existing class object, the class object's metamethods won't be copied. | 516 | Du kannst mit dem Schlüsselwort `using` mischen, um Funktionen aus einer einfachen Tabelle oder einem vordefinierten Klassenobjekt in deine neue Klasse zu kopieren. Beim Mischen mit einer einfachen Tabelle kannst du die Klassen-Indexing-Funktion (Metamethod `__index`) überschreiben. Beim Mischen mit einem bestehenden Klassenobjekt werden dessen Metamethoden nicht kopiert. |
| 517 | 517 | ||
| 518 | ```yuescript | 518 | ```yuescript |
| 519 | MyIndex = __index: var: 1 | 519 | MyIndex = __index: var: 1 |
| @@ -530,7 +530,7 @@ class Y using X | |||
| 530 | y = Y! | 530 | y = Y! |
| 531 | y\func! | 531 | y\func! |
| 532 | 532 | ||
| 533 | assert y.__class.__parent ~= X -- X is not parent of Y | 533 | assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y |
| 534 | ``` | 534 | ``` |
| 535 | <YueDisplay> | 535 | <YueDisplay> |
| 536 | 536 | ||
| @@ -549,7 +549,7 @@ class Y using X | |||
| 549 | y = Y! | 549 | y = Y! |
| 550 | y\func! | 550 | y\func! |
| 551 | 551 | ||
| 552 | assert y.__class.__parent ~= X -- X is not parent of Y | 552 | assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y |
| 553 | ``` | 553 | ``` |
| 554 | 554 | ||
| 555 | </YueDisplay> | 555 | </YueDisplay> |
diff --git a/doc/docs/de/doc/objects/with-statement.md b/doc/docs/de/doc/objects/with-statement.md index 7786803..446f837 100644 --- a/doc/docs/de/doc/objects/with-statement.md +++ b/doc/docs/de/doc/objects/with-statement.md | |||
| @@ -1,13 +1,12 @@ | |||
| 1 | # With Statement | 1 | # With-Statement |
| 2 | 2 | ||
| 3 | Ein häufiges Muster bei der Erstellung eines Objekts ist, unmittelbar danach eine Reihe von Funktionen aufzurufen und Eigenschaften zu setzen. | ||
| 3 | 4 | ||
| 4 | A common pattern involving the creation of an object is calling a series of functions and setting a series of properties immediately after creating it. | 5 | Das führt dazu, dass der Objektname mehrfach wiederholt wird und unnötiges Rauschen entsteht. Eine gängige Lösung ist, eine Tabelle als Argument zu übergeben, die eine Sammlung von Schlüsseln und Werten enthält, die überschrieben werden sollen. Der Nachteil ist, dass der Konstruktor dieses Objekts diese Form unterstützen muss. |
| 5 | 6 | ||
| 6 | This results in repeating the name of the object multiple times in code, adding unnecessary noise. A common solution to this is to pass a table in as an argument which contains a collection of keys and values to overwrite. The downside to this is that the constructor of this object must support this form. | 7 | Der `with`-Block hilft, das zu vermeiden. Innerhalb eines `with`-Blocks können wir spezielle Anweisungen verwenden, die mit `.` oder `\` beginnen und die Operationen auf das Objekt anwenden, mit dem wir gerade arbeiten. |
| 7 | 8 | ||
| 8 | The with block helps to alleviate this. Within a with block we can use a special statements that begin with either . or \ which represent those operations applied to the object we are using with on. | 9 | Zum Beispiel arbeiten wir mit einem neu erstellten Objekt: |
| 9 | |||
| 10 | For example, we work with a newly created object: | ||
| 11 | 10 | ||
| 12 | ```yuescript | 11 | ```yuescript |
| 13 | with Person! | 12 | with Person! |
| @@ -28,22 +27,22 @@ with Person! | |||
| 28 | 27 | ||
| 29 | </YueDisplay> | 28 | </YueDisplay> |
| 30 | 29 | ||
| 31 | The with statement can also be used as an expression which returns the value it has been giving access to. | 30 | Das `with`-Statement kann auch als Ausdruck verwendet werden und gibt den Wert zurück, auf den es Zugriff gewährt. |
| 32 | 31 | ||
| 33 | ```yuescript | 32 | ```yuescript |
| 34 | file = with File "favorite_foods.txt" | 33 | file = with File "Lieblingsessen.txt" |
| 35 | \set_encoding "utf8" | 34 | \set_encoding "utf8" |
| 36 | ``` | 35 | ``` |
| 37 | <YueDisplay> | 36 | <YueDisplay> |
| 38 | 37 | ||
| 39 | ```yue | 38 | ```yue |
| 40 | file = with File "favorite_foods.txt" | 39 | file = with File "Lieblingsessen.txt" |
| 41 | \set_encoding "utf8" | 40 | \set_encoding "utf8" |
| 42 | ``` | 41 | ``` |
| 43 | 42 | ||
| 44 | </YueDisplay> | 43 | </YueDisplay> |
| 45 | 44 | ||
| 46 | Or… | 45 | Oder … |
| 47 | 46 | ||
| 48 | ```yuescript | 47 | ```yuescript |
| 49 | create_person = (name, relatives) -> | 48 | create_person = (name, relatives) -> |
| @@ -66,26 +65,26 @@ me = create_person "Leaf", [dad, mother, sister] | |||
| 66 | 65 | ||
| 67 | </YueDisplay> | 66 | </YueDisplay> |
| 68 | 67 | ||
| 69 | In this usage, with can be seen as a special form of the K combinator. | 68 | In dieser Verwendung kann `with` als spezielle Form des K-Kombinators gesehen werden. |
| 70 | 69 | ||
| 71 | The expression in the with statement can also be an assignment, if you want to give a name to the expression. | 70 | Der Ausdruck im `with`-Statement kann auch eine Zuweisung sein, wenn du dem Ausdruck einen Namen geben willst. |
| 72 | 71 | ||
| 73 | ```yuescript | 72 | ```yuescript |
| 74 | with str := "Hello" | 73 | with str := "Hallo" |
| 75 | print "original:", str | 74 | print "Original:", str |
| 76 | print "upper:", \upper! | 75 | print "Großbuchstaben:", \upper! |
| 77 | ``` | 76 | ``` |
| 78 | <YueDisplay> | 77 | <YueDisplay> |
| 79 | 78 | ||
| 80 | ```yue | 79 | ```yue |
| 81 | with str := "Hello" | 80 | with str := "Hallo" |
| 82 | print "original:", str | 81 | print "Original:", str |
| 83 | print "upper:", \upper! | 82 | print "Großbuchstaben:", \upper! |
| 84 | ``` | 83 | ``` |
| 85 | 84 | ||
| 86 | </YueDisplay> | 85 | </YueDisplay> |
| 87 | 86 | ||
| 88 | You can access special keys with `[]` in a `with` statement. | 87 | Du kannst in einem `with`-Statement über `[]` auf spezielle Schlüssel zugreifen. |
| 89 | 88 | ||
| 90 | ```yuescript | 89 | ```yuescript |
| 91 | with tb | 90 | with tb |
| @@ -94,7 +93,7 @@ with tb | |||
| 94 | with [abc] | 93 | with [abc] |
| 95 | [3] = [2]\func! | 94 | [3] = [2]\func! |
| 96 | ["key-name"] = value | 95 | ["key-name"] = value |
| 97 | [] = "abc" -- appending to "tb" | 96 | [] = "abc" -- an "tb" anhängen |
| 98 | ``` | 97 | ``` |
| 99 | <YueDisplay> | 98 | <YueDisplay> |
| 100 | 99 | ||
| @@ -105,12 +104,12 @@ with tb | |||
| 105 | with [abc] | 104 | with [abc] |
| 106 | [3] = [2]\func! | 105 | [3] = [2]\func! |
| 107 | ["key-name"] = value | 106 | ["key-name"] = value |
| 108 | [] = "abc" -- appending to "tb" | 107 | [] = "abc" -- an "tb" anhängen |
| 109 | ``` | 108 | ``` |
| 110 | 109 | ||
| 111 | </YueDisplay> | 110 | </YueDisplay> |
| 112 | 111 | ||
| 113 | `with?` is an enhanced version of `with` syntax, which introduces an existential check to safely access objects that may be nil without explicit null checks. | 112 | `with?` ist eine erweiterte Version der `with`-Syntax, die einen Existenz-Check einführt, um Objekte, die `nil` sein könnten, sicher zuzugreifen, ohne explizite Nullprüfungen. |
| 114 | 113 | ||
| 115 | ```yuescript | 114 | ```yuescript |
| 116 | with? obj | 115 | with? obj |
diff --git a/doc/docs/de/doc/reference/license-mit.md b/doc/docs/de/doc/reference/license-mit.md index f1d5d60..a5e9f70 100644 --- a/doc/docs/de/doc/reference/license-mit.md +++ b/doc/docs/de/doc/reference/license-mit.md | |||
| @@ -1,23 +1,11 @@ | |||
| 1 | # License: MIT | 1 | # Lizenz: MIT |
| 2 | 2 | ||
| 3 | Copyright (c) 2017-2026 Li Jin \<dragon-fly@qq.com\> | 3 | Hinweis: Die MIT-Lizenz ist unten im englischen Originaltext wiedergegeben. |
| 4 | 4 | ||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | 5 | Urheberrecht (c) 2017-2026 Li Jin <dragon-fly@qq.com> |
| 6 | of this software and associated documentation files (the "Software"), to deal | ||
| 7 | in the Software without restriction, including without limitation the rights | ||
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | copies of the Software, and to permit persons to whom the Software is | ||
| 10 | furnished to do so, subject to the following conditions: | ||
| 11 | 6 | ||
| 12 | The above copyright notice and this permission notice shall be included in all | 7 | Hiermit wird unentgeltlich jeder Person, die eine Kopie dieser Software und der zugehörigen Dokumentationsdateien (die "Software") erhält, die Erlaubnis erteilt, uneingeschränkt mit der Software zu verfahren, einschließlich und ohne Beschränkung der Rechte, die Software zu benutzen, zu kopieren, zu verändern, zusammenzuführen, zu veröffentlichen, zu verbreiten, zu unterlizenzieren und/oder zu verkaufen, sowie Personen, denen die Software zur Verfügung gestellt wird, dies ebenfalls zu gestatten, unter den folgenden Bedingungen: |
| 13 | copies or substantial portions of the Software. | ||
| 14 | 8 | ||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 9 | Der obige Urheberrechtshinweis und dieser Genehmigungshinweis müssen in allen Kopien oder wesentlichen Teilen der Software enthalten sein. |
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | SOFTWARE. | ||
| 22 | 10 | ||
| 23 | <CompilerModal /> | 11 | DIE SOFTWARE WIRD OHNE JEGLICHE AUSDRÜCKLICHE ODER STILLSCHWEIGENDE GARANTIE ZUR VERFÜGUNG GESTELLT, EINSCHLIESSLICH DER GARANTIEN DER MARKTGÄNGIGKEIT, DER EIGNUNG FÜR EINEN BESTIMMTEN ZWECK UND DER NICHTVERLETZUNG. IN KEINEM FALL SIND DIE AUTOREN ODER URHEBERRECHTSINHABER FÜR ANSPRÜCHE, SCHÄDEN ODER SONSTIGE HAFTUNGEN VERANTWORTLICH, SEI ES AUS EINEM VERTRAG, EINER UNERLAUBTEN HANDLUNG ODER ANDERWEITIG, DIE SICH AUS DER SOFTWARE ODER DER BENUTZUNG DER SOFTWARE ODER ANDEREN GESCHÄFTEN MIT DER SOFTWARE ERGEBEN ODER DAMIT IN ZUSAMMENHANG STEHEN. |
diff --git a/doc/docs/de/doc/reference/the-yuescript-library.md b/doc/docs/de/doc/reference/the-yuescript-library.md index 3761755..1838ced 100644 --- a/doc/docs/de/doc/reference/the-yuescript-library.md +++ b/doc/docs/de/doc/reference/the-yuescript-library.md | |||
| @@ -1,61 +1,61 @@ | |||
| 1 | # The YueScript Library | 1 | # Die YueScript-Bibliothek |
| 2 | 2 | ||
| 3 | Access it by `local yue = require("yue")` in Lua. | 3 | Zugriff in Lua über `local yue = require("yue")`. |
| 4 | 4 | ||
| 5 | ## yue | 5 | ## yue |
| 6 | 6 | ||
| 7 | **Description:** | 7 | **Beschreibung:** |
| 8 | 8 | ||
| 9 | The YueScript language library. | 9 | Die YueScript-Sprachbibliothek. |
| 10 | 10 | ||
| 11 | ### version | 11 | ### version |
| 12 | 12 | ||
| 13 | **Type:** Field. | 13 | **Typ:** Feld. |
| 14 | 14 | ||
| 15 | **Description:** | 15 | **Beschreibung:** |
| 16 | 16 | ||
| 17 | The YueScript version. | 17 | Die YueScript-Version. |
| 18 | 18 | ||
| 19 | **Signature:** | 19 | **Signatur:** |
| 20 | ```lua | 20 | ```lua |
| 21 | version: string | 21 | version: string |
| 22 | ``` | 22 | ``` |
| 23 | 23 | ||
| 24 | ### dirsep | 24 | ### dirsep |
| 25 | 25 | ||
| 26 | **Type:** Field. | 26 | **Typ:** Feld. |
| 27 | 27 | ||
| 28 | **Description:** | 28 | **Beschreibung:** |
| 29 | 29 | ||
| 30 | The file separator for the current platform. | 30 | Der Dateitrennzeichen-String der aktuellen Plattform. |
| 31 | 31 | ||
| 32 | **Signature:** | 32 | **Signatur:** |
| 33 | ```lua | 33 | ```lua |
| 34 | dirsep: string | 34 | dirsep: string |
| 35 | ``` | 35 | ``` |
| 36 | 36 | ||
| 37 | ### yue_compiled | 37 | ### yue_compiled |
| 38 | 38 | ||
| 39 | **Type:** Field. | 39 | **Typ:** Feld. |
| 40 | 40 | ||
| 41 | **Description:** | 41 | **Beschreibung:** |
| 42 | 42 | ||
| 43 | The compiled module code cache. | 43 | Der Cache für kompilierten Modulcode. |
| 44 | 44 | ||
| 45 | **Signature:** | 45 | **Signatur:** |
| 46 | ```lua | 46 | ```lua |
| 47 | yue_compiled: {string: string} | 47 | yue_compiled: {string: string} |
| 48 | ``` | 48 | ``` |
| 49 | 49 | ||
| 50 | ### to_lua | 50 | ### to_lua |
| 51 | 51 | ||
| 52 | **Type:** Function. | 52 | **Typ:** Funktion. |
| 53 | 53 | ||
| 54 | **Description:** | 54 | **Beschreibung:** |
| 55 | 55 | ||
| 56 | The YueScript compiling function. It compiles the YueScript code to Lua code. | 56 | Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. |
| 57 | 57 | ||
| 58 | **Signature:** | 58 | **Signatur:** |
| 59 | ```lua | 59 | ```lua |
| 60 | to_lua: function(code: string, config?: Config): | 60 | to_lua: function(code: string, config?: Config): |
| 61 | --[[codes]] string | nil, | 61 | --[[codes]] string | nil, |
| @@ -63,682 +63,682 @@ to_lua: function(code: string, config?: Config): | |||
| 63 | --[[globals]] {{string, integer, integer}} | nil | 63 | --[[globals]] {{string, integer, integer}} | nil |
| 64 | ``` | 64 | ``` |
| 65 | 65 | ||
| 66 | **Parameters:** | 66 | **Parameter:** |
| 67 | 67 | ||
| 68 | | Parameter | Type | Description | | 68 | | Parameter | Typ | Beschreibung | |
| 69 | | --- | --- | --- | | 69 | | --- | --- | --- | |
| 70 | | code | string | The YueScript code. | | 70 | | code | string | Der YueScript-Code. | |
| 71 | | config | Config | [Optional] The compiler options. | | 71 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 72 | 72 | ||
| 73 | **Returns:** | 73 | **Rückgabe:** |
| 74 | 74 | ||
| 75 | | Return Type | Description | | 75 | | Rückgabetyp | Beschreibung | |
| 76 | | --- | --- | | 76 | | --- | --- | |
| 77 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | | 77 | | string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | |
| 78 | | string \| nil | The error message, or nil if the compilation succeeded. | | 78 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | |
| 79 | | {{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | | 79 | | {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | |
| 80 | 80 | ||
| 81 | ### file_exist | 81 | ### file_exist |
| 82 | 82 | ||
| 83 | **Type:** Function. | 83 | **Typ:** Funktion. |
| 84 | 84 | ||
| 85 | **Description:** | 85 | **Beschreibung:** |
| 86 | 86 | ||
| 87 | The source file existence checking function. Can be overridden to customize the behavior. | 87 | Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. |
| 88 | 88 | ||
| 89 | **Signature:** | 89 | **Signatur:** |
| 90 | ```lua | 90 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 91 | file_exist: function(filename: string): boolean |
| 92 | ``` | 92 | ``` |
| 93 | 93 | ||
| 94 | **Parameters:** | 94 | **Parameter:** |
| 95 | 95 | ||
| 96 | | Parameter | Type | Description | | 96 | | Parameter | Typ | Beschreibung | |
| 97 | | --- | --- | --- | | 97 | | --- | --- | --- | |
| 98 | | filename | string | The file name. | | 98 | | filename | string | Der Dateiname. | |
| 99 | 99 | ||
| 100 | **Returns:** | 100 | **Rückgabe:** |
| 101 | 101 | ||
| 102 | | Return Type | Description | | 102 | | Rückgabetyp | Beschreibung | |
| 103 | | --- | --- | | 103 | | --- | --- | |
| 104 | | boolean | Whether the file exists. | | 104 | | boolean | Ob die Datei existiert. | |
| 105 | 105 | ||
| 106 | ### read_file | 106 | ### read_file |
| 107 | 107 | ||
| 108 | **Type:** Function. | 108 | **Typ:** Funktion. |
| 109 | 109 | ||
| 110 | **Description:** | 110 | **Beschreibung:** |
| 111 | 111 | ||
| 112 | The source file reading function. Can be overridden to customize the behavior. | 112 | Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. |
| 113 | 113 | ||
| 114 | **Signature:** | 114 | **Signatur:** |
| 115 | ```lua | 115 | ```lua |
| 116 | read_file: function(filename: string): string | 116 | read_file: function(filename: string): string |
| 117 | ``` | 117 | ``` |
| 118 | 118 | ||
| 119 | **Parameters:** | 119 | **Parameter:** |
| 120 | 120 | ||
| 121 | | Parameter | Type | Description | | 121 | | Parameter | Typ | Beschreibung | |
| 122 | | --- | --- | --- | | 122 | | --- | --- | --- | |
| 123 | | filename | string | The file name. | | 123 | | filename | string | Der Dateiname. | |
| 124 | 124 | ||
| 125 | **Returns:** | 125 | **Rückgabe:** |
| 126 | 126 | ||
| 127 | | Return Type | Description | | 127 | | Rückgabetyp | Beschreibung | |
| 128 | | --- | --- | | 128 | | --- | --- | |
| 129 | | string | The file content. | | 129 | | string | Der Dateiinhalt. | |
| 130 | 130 | ||
| 131 | ### insert_loader | 131 | ### insert_loader |
| 132 | 132 | ||
| 133 | **Type:** Function. | 133 | **Typ:** Funktion. |
| 134 | 134 | ||
| 135 | **Description:** | 135 | **Beschreibung:** |
| 136 | 136 | ||
| 137 | Insert the YueScript loader to the package loaders (searchers). | 137 | Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. |
| 138 | 138 | ||
| 139 | **Signature:** | 139 | **Signatur:** |
| 140 | ```lua | 140 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 141 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 142 | ``` |
| 143 | 143 | ||
| 144 | **Parameters:** | 144 | **Parameter:** |
| 145 | 145 | ||
| 146 | | Parameter | Type | Description | | 146 | | Parameter | Typ | Beschreibung | |
| 147 | | --- | --- | --- | | 147 | | --- | --- | --- | |
| 148 | | pos | integer | [Optional] The position to insert the loader. Default is 3. | | 148 | | pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | |
| 149 | 149 | ||
| 150 | **Returns:** | 150 | **Rückgabe:** |
| 151 | 151 | ||
| 152 | | Return Type | Description | | 152 | | Rückgabetyp | Beschreibung | |
| 153 | | --- | --- | | 153 | | --- | --- | |
| 154 | | boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | | 154 | | boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | |
| 155 | 155 | ||
| 156 | ### remove_loader | 156 | ### remove_loader |
| 157 | 157 | ||
| 158 | **Type:** Function. | 158 | **Typ:** Funktion. |
| 159 | 159 | ||
| 160 | **Description:** | 160 | **Beschreibung:** |
| 161 | 161 | ||
| 162 | Remove the YueScript loader from the package loaders (searchers). | 162 | Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). |
| 163 | 163 | ||
| 164 | **Signature:** | 164 | **Signatur:** |
| 165 | ```lua | 165 | ```lua |
| 166 | remove_loader: function(): boolean | 166 | remove_loader: function(): boolean |
| 167 | ``` | 167 | ``` |
| 168 | 168 | ||
| 169 | **Returns:** | 169 | **Rückgabe:** |
| 170 | 170 | ||
| 171 | | Return Type | Description | | 171 | | Rückgabetyp | Beschreibung | |
| 172 | | --- | --- | | 172 | | --- | --- | |
| 173 | | boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | | 173 | | boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | |
| 174 | 174 | ||
| 175 | ### loadstring | 175 | ### loadstring |
| 176 | 176 | ||
| 177 | **Type:** Function. | 177 | **Typ:** Funktion. |
| 178 | 178 | ||
| 179 | **Description:** | 179 | **Beschreibung:** |
| 180 | 180 | ||
| 181 | Loads YueScript code from a string into a function. | 181 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 182 | 182 | ||
| 183 | **Signature:** | 183 | **Signatur:** |
| 184 | ```lua | 184 | ```lua |
| 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 185 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): |
| 186 | --[[loaded function]] nil | function(...: any): (any...), | 186 | --[[loaded function]] nil | function(...: any): (any...), |
| 187 | --[[error]] string | nil | 187 | --[[error]] string | nil |
| 188 | ``` | 188 | ``` |
| 189 | 189 | ||
| 190 | **Parameters:** | 190 | **Parameter:** |
| 191 | 191 | ||
| 192 | | Parameter | Type | Description | | 192 | | Parameter | Typ | Beschreibung | |
| 193 | | --- | --- | --- | | 193 | | --- | --- | --- | |
| 194 | | input | string | The YueScript code. | | 194 | | input | string | Der YueScript-Code. | |
| 195 | | chunkname | string | The name of the code chunk. | | 195 | | chunkname | string | Der Name des Code-Chunks. | |
| 196 | | env | table | The environment table. | | 196 | | env | table | Die Environment-Tabelle. | |
| 197 | | config | Config | [Optional] The compiler options. | | 197 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 198 | 198 | ||
| 199 | **Returns:** | 199 | **Rückgabe:** |
| 200 | 200 | ||
| 201 | | Return Type | Description | | 201 | | Rückgabetyp | Beschreibung | |
| 202 | | --- | --- | | 202 | | --- | --- | |
| 203 | | function \| nil | The loaded function, or nil if the loading failed. | | 203 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 204 | | string \| nil | The error message, or nil if the loading succeeded. | | 204 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 205 | 205 | ||
| 206 | ### loadstring | 206 | ### loadstring |
| 207 | 207 | ||
| 208 | **Type:** Function. | 208 | **Typ:** Funktion. |
| 209 | 209 | ||
| 210 | **Description:** | 210 | **Beschreibung:** |
| 211 | 211 | ||
| 212 | Loads YueScript code from a string into a function. | 212 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 213 | 213 | ||
| 214 | **Signature:** | 214 | **Signatur:** |
| 215 | ```lua | 215 | ```lua |
| 216 | loadstring: function(input: string, chunkname: string, config?: Config): | 216 | loadstring: function(input: string, chunkname: string, config?: Config): |
| 217 | --[[loaded function]] nil | function(...: any): (any...), | 217 | --[[loaded function]] nil | function(...: any): (any...), |
| 218 | --[[error]] string | nil | 218 | --[[error]] string | nil |
| 219 | ``` | 219 | ``` |
| 220 | 220 | ||
| 221 | **Parameters:** | 221 | **Parameter:** |
| 222 | 222 | ||
| 223 | | Parameter | Type | Description | | 223 | | Parameter | Typ | Beschreibung | |
| 224 | | --- | --- | --- | | 224 | | --- | --- | --- | |
| 225 | | input | string | The YueScript code. | | 225 | | input | string | Der YueScript-Code. | |
| 226 | | chunkname | string | The name of the code chunk. | | 226 | | chunkname | string | Der Name des Code-Chunks. | |
| 227 | | config | Config | [Optional] The compiler options. | | 227 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 228 | 228 | ||
| 229 | **Returns:** | 229 | **Rückgabe:** |
| 230 | 230 | ||
| 231 | | Return Type | Description | | 231 | | Rückgabetyp | Beschreibung | |
| 232 | | --- | --- | | 232 | | --- | --- | |
| 233 | | function \| nil | The loaded function, or nil if the loading failed. | | 233 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 234 | | string \| nil | The error message, or nil if the loading succeeded. | | 234 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 235 | 235 | ||
| 236 | ### loadstring | 236 | ### loadstring |
| 237 | 237 | ||
| 238 | **Type:** Function. | 238 | **Typ:** Funktion. |
| 239 | 239 | ||
| 240 | **Description:** | 240 | **Beschreibung:** |
| 241 | 241 | ||
| 242 | Loads YueScript code from a string into a function. | 242 | Lädt YueScript-Code aus einem String in eine Funktion. |
| 243 | 243 | ||
| 244 | **Signature:** | 244 | **Signatur:** |
| 245 | ```lua | 245 | ```lua |
| 246 | loadstring: function(input: string, config?: Config): | 246 | loadstring: function(input: string, config?: Config): |
| 247 | --[[loaded function]] nil | function(...: any): (any...), | 247 | --[[loaded function]] nil | function(...: any): (any...), |
| 248 | --[[error]] string | nil | 248 | --[[error]] string | nil |
| 249 | ``` | 249 | ``` |
| 250 | 250 | ||
| 251 | **Parameters:** | 251 | **Parameter:** |
| 252 | 252 | ||
| 253 | | Parameter | Type | Description | | 253 | | Parameter | Typ | Beschreibung | |
| 254 | | --- | --- | --- | | 254 | | --- | --- | --- | |
| 255 | | input | string | The YueScript code. | | 255 | | input | string | Der YueScript-Code. | |
| 256 | | config | Config | [Optional] The compiler options. | | 256 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 257 | 257 | ||
| 258 | **Returns:** | 258 | **Rückgabe:** |
| 259 | 259 | ||
| 260 | | Return Type | Description | | 260 | | Rückgabetyp | Beschreibung | |
| 261 | | --- | --- | | 261 | | --- | --- | |
| 262 | | function \| nil | The loaded function, or nil if the loading failed. | | 262 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 263 | | string \| nil | The error message, or nil if the loading succeeded. | | 263 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 264 | 264 | ||
| 265 | ### loadfile | 265 | ### loadfile |
| 266 | 266 | ||
| 267 | **Type:** Function. | 267 | **Typ:** Funktion. |
| 268 | 268 | ||
| 269 | **Description:** | 269 | **Beschreibung:** |
| 270 | 270 | ||
| 271 | Loads YueScript code from a file into a function. | 271 | Lädt YueScript-Code aus einer Datei in eine Funktion. |
| 272 | 272 | ||
| 273 | **Signature:** | 273 | **Signatur:** |
| 274 | ```lua | 274 | ```lua |
| 275 | loadfile: function(filename: string, env: table, config?: Config): | 275 | loadfile: function(filename: string, env: table, config?: Config): |
| 276 | nil | function(...: any): (any...), | 276 | nil | function(...: any): (any...), |
| 277 | string | nil | 277 | string | nil |
| 278 | ``` | 278 | ``` |
| 279 | 279 | ||
| 280 | **Parameters:** | 280 | **Parameter:** |
| 281 | 281 | ||
| 282 | | Parameter | Type | Description | | 282 | | Parameter | Typ | Beschreibung | |
| 283 | | --- | --- | --- | | 283 | | --- | --- | --- | |
| 284 | | filename | string | The file name. | | 284 | | filename | string | Der Dateiname. | |
| 285 | | env | table | The environment table. | | 285 | | env | table | Die Environment-Tabelle. | |
| 286 | | config | Config | [Optional] The compiler options. | | 286 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 287 | 287 | ||
| 288 | **Returns:** | 288 | **Rückgabe:** |
| 289 | 289 | ||
| 290 | | Return Type | Description | | 290 | | Rückgabetyp | Beschreibung | |
| 291 | | --- | --- | | 291 | | --- | --- | |
| 292 | | function \| nil | The loaded function, or nil if the loading failed. | | 292 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 293 | | string \| nil | The error message, or nil if the loading succeeded. | | 293 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 294 | 294 | ||
| 295 | ### loadfile | 295 | ### loadfile |
| 296 | 296 | ||
| 297 | **Type:** Function. | 297 | **Typ:** Funktion. |
| 298 | 298 | ||
| 299 | **Description:** | 299 | **Beschreibung:** |
| 300 | 300 | ||
| 301 | Loads YueScript code from a file into a function. | 301 | Lädt YueScript-Code aus einer Datei in eine Funktion. |
| 302 | 302 | ||
| 303 | **Signature:** | 303 | **Signatur:** |
| 304 | ```lua | 304 | ```lua |
| 305 | loadfile: function(filename: string, config?: Config): | 305 | loadfile: function(filename: string, config?: Config): |
| 306 | nil | function(...: any): (any...), | 306 | nil | function(...: any): (any...), |
| 307 | string | nil | 307 | string | nil |
| 308 | ``` | 308 | ``` |
| 309 | 309 | ||
| 310 | **Parameters:** | 310 | **Parameter:** |
| 311 | 311 | ||
| 312 | | Parameter | Type | Description | | 312 | | Parameter | Typ | Beschreibung | |
| 313 | | --- | --- | --- | | 313 | | --- | --- | --- | |
| 314 | | filename | string | The file name. | | 314 | | filename | string | Der Dateiname. | |
| 315 | | config | Config | [Optional] The compiler options. | | 315 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 316 | 316 | ||
| 317 | **Returns:** | 317 | **Rückgabe:** |
| 318 | 318 | ||
| 319 | | Return Type | Description | | 319 | | Rückgabetyp | Beschreibung | |
| 320 | | --- | --- | | 320 | | --- | --- | |
| 321 | | function \| nil | The loaded function, or nil if the loading failed. | | 321 | | function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | |
| 322 | | string \| nil | The error message, or nil if the loading succeeded. | | 322 | | string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | |
| 323 | 323 | ||
| 324 | ### dofile | 324 | ### dofile |
| 325 | 325 | ||
| 326 | **Type:** Function. | 326 | **Typ:** Funktion. |
| 327 | 327 | ||
| 328 | **Description:** | 328 | **Beschreibung:** |
| 329 | 329 | ||
| 330 | Loads YueScript code from a file into a function and executes it. | 330 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. |
| 331 | 331 | ||
| 332 | **Signature:** | 332 | **Signatur:** |
| 333 | ```lua | 333 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 334 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 335 | ``` |
| 336 | 336 | ||
| 337 | **Parameters:** | 337 | **Parameter:** |
| 338 | 338 | ||
| 339 | | Parameter | Type | Description | | 339 | | Parameter | Typ | Beschreibung | |
| 340 | | --- | --- | --- | | 340 | | --- | --- | --- | |
| 341 | | filename | string | The file name. | | 341 | | filename | string | Der Dateiname. | |
| 342 | | env | table | The environment table. | | 342 | | env | table | Die Environment-Tabelle. | |
| 343 | | config | Config | [Optional] The compiler options. | | 343 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 344 | 344 | ||
| 345 | **Returns:** | 345 | **Rückgabe:** |
| 346 | 346 | ||
| 347 | | Return Type | Description | | 347 | | Rückgabetyp | Beschreibung | |
| 348 | | --- | --- | | 348 | | --- | --- | |
| 349 | | any... | The return values of the loaded function. | | 349 | | any... | Die Rückgabewerte der geladenen Funktion. | |
| 350 | 350 | ||
| 351 | ### dofile | 351 | ### dofile |
| 352 | 352 | ||
| 353 | **Type:** Function. | 353 | **Typ:** Funktion. |
| 354 | 354 | ||
| 355 | **Description:** | 355 | **Beschreibung:** |
| 356 | 356 | ||
| 357 | Loads YueScript code from a file into a function and executes it. | 357 | Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. |
| 358 | 358 | ||
| 359 | **Signature:** | 359 | **Signatur:** |
| 360 | ```lua | 360 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 361 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 362 | ``` |
| 363 | 363 | ||
| 364 | **Parameters:** | 364 | **Parameter:** |
| 365 | 365 | ||
| 366 | | Parameter | Type | Description | | 366 | | Parameter | Typ | Beschreibung | |
| 367 | | --- | --- | --- | | 367 | | --- | --- | --- | |
| 368 | | filename | string | The file name. | | 368 | | filename | string | Der Dateiname. | |
| 369 | | config | Config | [Optional] The compiler options. | | 369 | | config | Config | [Optional] Die Compiler-Optionen. | |
| 370 | 370 | ||
| 371 | **Returns:** | 371 | **Rückgabe:** |
| 372 | 372 | ||
| 373 | | Return Type | Description | | 373 | | Rückgabetyp | Beschreibung | |
| 374 | | --- | --- | | 374 | | --- | --- | |
| 375 | | any... | The return values of the loaded function. | | 375 | | any... | Die Rückgabewerte der geladenen Funktion. | |
| 376 | 376 | ||
| 377 | ### find_modulepath | 377 | ### find_modulepath |
| 378 | 378 | ||
| 379 | **Type:** Function. | 379 | **Typ:** Funktion. |
| 380 | 380 | ||
| 381 | **Description:** | 381 | **Beschreibung:** |
| 382 | 382 | ||
| 383 | Resolves the YueScript module name to the file path. | 383 | Löst den YueScript-Modulnamen in einen Dateipfad auf. |
| 384 | 384 | ||
| 385 | **Signature:** | 385 | **Signatur:** |
| 386 | ```lua | 386 | ```lua |
| 387 | find_modulepath: function(name: string): string | 387 | find_modulepath: function(name: string): string |
| 388 | ``` | 388 | ``` |
| 389 | 389 | ||
| 390 | **Parameters:** | 390 | **Parameter:** |
| 391 | 391 | ||
| 392 | | Parameter | Type | Description | | 392 | | Parameter | Typ | Beschreibung | |
| 393 | | --- | --- | --- | | 393 | | --- | --- | --- | |
| 394 | | name | string | The module name. | | 394 | | name | string | Der Modulname. | |
| 395 | 395 | ||
| 396 | **Returns:** | 396 | **Rückgabe:** |
| 397 | 397 | ||
| 398 | | Return Type | Description | | 398 | | Rückgabetyp | Beschreibung | |
| 399 | | --- | --- | | 399 | | --- | --- | |
| 400 | | string | The file path. | | 400 | | string | Der Dateipfad. | |
| 401 | 401 | ||
| 402 | ### pcall | 402 | ### pcall |
| 403 | 403 | ||
| 404 | **Type:** Function. | 404 | **Typ:** Funktion. |
| 405 | 405 | ||
| 406 | **Description:** | 406 | **Beschreibung:** |
| 407 | 407 | ||
| 408 | Calls a function in protected mode. | 408 | Ruft eine Funktion im geschützten Modus auf. |
| 409 | Catches any errors and returns a status code and results or error object. | 409 | Fängt Fehler ab und gibt einen Statuscode sowie Ergebnisse oder ein Fehlerobjekt zurück. |
| 410 | Rewrites the error line number to the original line number in the YueScript code when errors occur. | 410 | Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. |
| 411 | 411 | ||
| 412 | **Signature:** | 412 | **Signatur:** |
| 413 | ```lua | 413 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 414 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 415 | ``` |
| 416 | 416 | ||
| 417 | **Parameters:** | 417 | **Parameter:** |
| 418 | 418 | ||
| 419 | | Parameter | Type | Description | | 419 | | Parameter | Typ | Beschreibung | |
| 420 | | --- | --- | --- | | 420 | | --- | --- | --- | |
| 421 | | f | function | The function to call. | | 421 | | f | function | Die aufzurufende Funktion. | |
| 422 | | ... | any | Arguments to pass to the function. | | 422 | | ... | any | Argumente für die Funktion. | |
| 423 | 423 | ||
| 424 | **Returns:** | 424 | **Rückgabe:** |
| 425 | 425 | ||
| 426 | | Return Type | Description | | 426 | | Rückgabetyp | Beschreibung | |
| 427 | | --- | --- | | 427 | | --- | --- | |
| 428 | | boolean, ... | Status code and function results or error object. | | 428 | | boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | |
| 429 | 429 | ||
| 430 | ### require | 430 | ### require |
| 431 | 431 | ||
| 432 | **Type:** Function. | 432 | **Typ:** Funktion. |
| 433 | 433 | ||
| 434 | **Description:** | 434 | **Beschreibung:** |
| 435 | 435 | ||
| 436 | Loads a given module. Can be either a Lua module or a YueScript module. | 436 | Lädt ein Modul (Lua oder YueScript). |
| 437 | Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. | 437 | Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. |
| 438 | 438 | ||
| 439 | **Signature:** | 439 | **Signatur:** |
| 440 | ```lua | 440 | ```lua |
| 441 | require: function(name: string): any... | 441 | require: function(name: string): any... |
| 442 | ``` | 442 | ``` |
| 443 | 443 | ||
| 444 | **Parameters:** | 444 | **Parameter:** |
| 445 | 445 | ||
| 446 | | Parameter | Type | Description | | 446 | | Parameter | Typ | Beschreibung | |
| 447 | | --- | --- | --- | | 447 | | --- | --- | --- | |
| 448 | | modname | string | The name of the module to load. | | 448 | | modname | string | Der Name des zu ladenden Moduls. | |
| 449 | 449 | ||
| 450 | **Returns:** | 450 | **Rückgabe:** |
| 451 | 451 | ||
| 452 | | Return Type | Description | | 452 | | Rückgabetyp | Beschreibung | |
| 453 | | --- | --- | | 453 | | --- | --- | |
| 454 | | any | The value stored at package.loaded[modname] if the module is already loaded.Otherwise, tries to find a loader and returns the final value of package.loaded[modname] and a loader data as a second result. | | 454 | | any | Der Wert in `package.loaded[modname]`, falls das Modul bereits geladen ist. Andernfalls wird ein Loader gesucht und der finale Wert von `package.loaded[modname]` sowie Loader-Daten als zweites Ergebnis zurückgegeben. | |
| 455 | 455 | ||
| 456 | ### p | 456 | ### p |
| 457 | 457 | ||
| 458 | **Type:** Function. | 458 | **Typ:** Funktion. |
| 459 | 459 | ||
| 460 | **Description:** | 460 | **Beschreibung:** |
| 461 | 461 | ||
| 462 | Inspects the structures of the passed values and prints string representations. | 462 | Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. |
| 463 | 463 | ||
| 464 | **Signature:** | 464 | **Signatur:** |
| 465 | ```lua | 465 | ```lua |
| 466 | p: function(...: any) | 466 | p: function(...: any) |
| 467 | ``` | 467 | ``` |
| 468 | 468 | ||
| 469 | **Parameters:** | 469 | **Parameter:** |
| 470 | 470 | ||
| 471 | | Parameter | Type | Description | | 471 | | Parameter | Typ | Beschreibung | |
| 472 | | --- | --- | --- | | 472 | | --- | --- | --- | |
| 473 | | ... | any | The values to inspect. | | 473 | | ... | any | Die zu inspizierenden Werte. | |
| 474 | 474 | ||
| 475 | ### options | 475 | ### options |
| 476 | 476 | ||
| 477 | **Type:** Field. | 477 | **Typ:** Feld. |
| 478 | 478 | ||
| 479 | **Description:** | 479 | **Beschreibung:** |
| 480 | 480 | ||
| 481 | The current compiler options. | 481 | Die aktuellen Compiler-Optionen. |
| 482 | 482 | ||
| 483 | **Signature:** | 483 | **Signatur:** |
| 484 | ```lua | 484 | ```lua |
| 485 | options: Config.Options | 485 | options: Config.Options |
| 486 | ``` | 486 | ``` |
| 487 | 487 | ||
| 488 | ### traceback | 488 | ### traceback |
| 489 | 489 | ||
| 490 | **Type:** Function. | 490 | **Typ:** Funktion. |
| 491 | 491 | ||
| 492 | **Description:** | 492 | **Beschreibung:** |
| 493 | 493 | ||
| 494 | The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. | 494 | Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. |
| 495 | 495 | ||
| 496 | **Signature:** | 496 | **Signatur:** |
| 497 | ```lua | 497 | ```lua |
| 498 | traceback: function(message: string): string | 498 | traceback: function(message: string): string |
| 499 | ``` | 499 | ``` |
| 500 | 500 | ||
| 501 | **Parameters:** | 501 | **Parameter:** |
| 502 | 502 | ||
| 503 | | Parameter | Type | Description | | 503 | | Parameter | Typ | Beschreibung | |
| 504 | | --- | --- | --- | | 504 | | --- | --- | --- | |
| 505 | | message | string | The traceback message. | | 505 | | message | string | Die Traceback-Nachricht. | |
| 506 | 506 | ||
| 507 | **Returns:** | 507 | **Rückgabe:** |
| 508 | 508 | ||
| 509 | | Return Type | Description | | 509 | | Rückgabetyp | Beschreibung | |
| 510 | | --- | --- | | 510 | | --- | --- | |
| 511 | | string | The rewritten traceback message. | | 511 | | string | Die umgeschriebene Traceback-Nachricht. | |
| 512 | 512 | ||
| 513 | ### is_ast | 513 | ### is_ast |
| 514 | 514 | ||
| 515 | **Type:** Function. | 515 | **Typ:** Funktion. |
| 516 | 516 | ||
| 517 | **Description:** | 517 | **Beschreibung:** |
| 518 | 518 | ||
| 519 | Checks whether the code matches the specified AST. | 519 | Prüft, ob der Code dem angegebenen AST entspricht. |
| 520 | 520 | ||
| 521 | **Signature:** | 521 | **Signatur:** |
| 522 | ```lua | 522 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 523 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 524 | ``` |
| 525 | 525 | ||
| 526 | **Parameters:** | 526 | **Parameter:** |
| 527 | 527 | ||
| 528 | | Parameter | Type | Description | | 528 | | Parameter | Typ | Beschreibung | |
| 529 | | --- | --- | --- | | 529 | | --- | --- | --- | |
| 530 | | astName | string | The AST name. | | 530 | | astName | string | Der AST-Name. | |
| 531 | | code | string | The code. | | 531 | | code | string | Der Code. | |
| 532 | 532 | ||
| 533 | **Returns:** | 533 | **Rückgabe:** |
| 534 | 534 | ||
| 535 | | Return Type | Description | | 535 | | Rückgabetyp | Beschreibung | |
| 536 | | --- | --- | | 536 | | --- | --- | |
| 537 | | boolean | Whether the code matches the AST. | | 537 | | boolean | Ob der Code dem AST entspricht. | |
| 538 | 538 | ||
| 539 | ### AST | 539 | ### AST |
| 540 | 540 | ||
| 541 | **Type:** Field. | 541 | **Typ:** Feld. |
| 542 | 542 | ||
| 543 | **Description:** | 543 | **Beschreibung:** |
| 544 | 544 | ||
| 545 | The AST type definition with name, row, column and sub nodes. | 545 | Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. |
| 546 | 546 | ||
| 547 | **Signature:** | 547 | **Signatur:** |
| 548 | ```lua | 548 | ```lua |
| 549 | type AST = {string, integer, integer, any} | 549 | type AST = {string, integer, integer, any} |
| 550 | ``` | 550 | ``` |
| 551 | 551 | ||
| 552 | ### to_ast | 552 | ### to_ast |
| 553 | 553 | ||
| 554 | **Type:** Function. | 554 | **Typ:** Funktion. |
| 555 | 555 | ||
| 556 | **Description:** | 556 | **Beschreibung:** |
| 557 | 557 | ||
| 558 | Converts the code to the AST. | 558 | Konvertiert Code in AST. |
| 559 | 559 | ||
| 560 | **Signature:** | 560 | **Signatur:** |
| 561 | ```lua | 561 | ```lua |
| 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 562 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): |
| 563 | --[[AST]] AST | nil, | 563 | --[[AST]] AST | nil, |
| 564 | --[[error]] nil | string | 564 | --[[error]] nil | string |
| 565 | ``` | 565 | ``` |
| 566 | 566 | ||
| 567 | **Parameters:** | 567 | **Parameter:** |
| 568 | 568 | ||
| 569 | | Parameter | Type | Description | | 569 | | Parameter | Typ | Beschreibung | |
| 570 | | --- | --- | --- | | 570 | | --- | --- | --- | |
| 571 | | code | string | The code. | | 571 | | code | string | Der Code. | |
| 572 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | | 572 | | flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | |
| 573 | | astName | string | [Optional] The AST name. Default is "File". | | 573 | | astName | string | [Optional] Der AST-Name. Standard ist "File". | |
| 574 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | | 574 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | |
| 575 | 575 | ||
| 576 | **Returns:** | 576 | **Rückgabe:** |
| 577 | 577 | ||
| 578 | | Return Type | Description | | 578 | | Rückgabetyp | Beschreibung | |
| 579 | | --- | --- | | 579 | | --- | --- | |
| 580 | | AST \| nil | The AST, or nil if the conversion failed. | | 580 | | AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | |
| 581 | | string \| nil | The error message, or nil if the conversion succeeded. | | 581 | | string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | |
| 582 | 582 | ||
| 583 | ### format | 583 | ### format |
| 584 | 584 | ||
| 585 | **Type:** Function. | 585 | **Typ:** Funktion. |
| 586 | 586 | ||
| 587 | **Description:** | 587 | **Beschreibung:** |
| 588 | 588 | ||
| 589 | Formats the YueScript code. | 589 | Formatiert den YueScript-Code. |
| 590 | 590 | ||
| 591 | **Signature:** | 591 | **Signatur:** |
| 592 | ```lua | 592 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 594 | ``` |
| 595 | 595 | ||
| 596 | **Parameters:** | 596 | **Parameter:** |
| 597 | 597 | ||
| 598 | | Parameter | Type | Description | | 598 | | Parameter | Typ | Beschreibung | |
| 599 | | --- | --- | --- | | 599 | | --- | --- | --- | |
| 600 | | code | string | The code. | | 600 | | code | string | Der Code. | |
| 601 | | tabSize | integer | [Optional] The tab size. Default is 4. | | 601 | | tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | |
| 602 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | | 602 | | reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | |
| 603 | 603 | ||
| 604 | **Returns:** | 604 | **Rückgabe:** |
| 605 | 605 | ||
| 606 | | Return Type | Description | | 606 | | Rückgabetyp | Beschreibung | |
| 607 | | --- | --- | | 607 | | --- | --- | |
| 608 | | string | The formatted code. | | 608 | | string | Der formatierte Code. | |
| 609 | 609 | ||
| 610 | ### __call | 610 | ### __call |
| 611 | 611 | ||
| 612 | **Type:** Metamethod. | 612 | **Typ:** Metamethod. |
| 613 | 613 | ||
| 614 | **Description:** | 614 | **Beschreibung:** |
| 615 | 615 | ||
| 616 | Requires the YueScript module. | 616 | Required das YueScript-Modul. |
| 617 | Rewrites the error line number to the original line number in the YueScript code when loading fails. | 617 | Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. |
| 618 | 618 | ||
| 619 | **Signature:** | 619 | **Signatur:** |
| 620 | ```lua | 620 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 621 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 622 | ``` |
| 623 | 623 | ||
| 624 | **Parameters:** | 624 | **Parameter:** |
| 625 | 625 | ||
| 626 | | Parameter | Type | Description | | 626 | | Parameter | Typ | Beschreibung | |
| 627 | | --- | --- | --- | | 627 | | --- | --- | --- | |
| 628 | | module | string | The module name. | | 628 | | module | string | Der Modulname. | |
| 629 | 629 | ||
| 630 | **Returns:** | 630 | **Rückgabe:** |
| 631 | 631 | ||
| 632 | | Return Type | Description | | 632 | | Rückgabetyp | Beschreibung | |
| 633 | | --- | --- | | 633 | | --- | --- | |
| 634 | | any | The module value. | | 634 | | any | Der Modulwert. | |
| 635 | 635 | ||
| 636 | ## Config | 636 | ## Config |
| 637 | 637 | ||
| 638 | **Description:** | 638 | **Beschreibung:** |
| 639 | 639 | ||
| 640 | The compiler compile options. | 640 | Die Compiler-Optionen. |
| 641 | 641 | ||
| 642 | ### lint_global | 642 | ### lint_global |
| 643 | 643 | ||
| 644 | **Type:** Field. | 644 | **Typ:** Feld. |
| 645 | 645 | ||
| 646 | **Description:** | 646 | **Beschreibung:** |
| 647 | 647 | ||
| 648 | Whether the compiler should collect the global variables appearing in the code. | 648 | Ob der Compiler die globalen Variablen im Code sammeln soll. |
| 649 | 649 | ||
| 650 | **Signature:** | 650 | **Signatur:** |
| 651 | ```lua | 651 | ```lua |
| 652 | lint_global: boolean | 652 | lint_global: boolean |
| 653 | ``` | 653 | ``` |
| 654 | 654 | ||
| 655 | ### implicit_return_root | 655 | ### implicit_return_root |
| 656 | 656 | ||
| 657 | **Type:** Field. | 657 | **Typ:** Feld. |
| 658 | 658 | ||
| 659 | **Description:** | 659 | **Beschreibung:** |
| 660 | 660 | ||
| 661 | Whether the compiler should do an implicit return for the root code block. | 661 | Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. |
| 662 | 662 | ||
| 663 | **Signature:** | 663 | **Signatur:** |
| 664 | ```lua | 664 | ```lua |
| 665 | implicit_return_root: boolean | 665 | implicit_return_root: boolean |
| 666 | ``` | 666 | ``` |
| 667 | 667 | ||
| 668 | ### reserve_line_number | 668 | ### reserve_line_number |
| 669 | 669 | ||
| 670 | **Type:** Field. | 670 | **Typ:** Feld. |
| 671 | 671 | ||
| 672 | **Description:** | 672 | **Beschreibung:** |
| 673 | 673 | ||
| 674 | Whether the compiler should reserve the original line number in the compiled code. | 674 | Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. |
| 675 | 675 | ||
| 676 | **Signature:** | 676 | **Signatur:** |
| 677 | ```lua | 677 | ```lua |
| 678 | reserve_line_number: boolean | 678 | reserve_line_number: boolean |
| 679 | ``` | 679 | ``` |
| 680 | 680 | ||
| 681 | ### reserve_comment | 681 | ### reserve_comment |
| 682 | 682 | ||
| 683 | **Type:** Field. | 683 | **Typ:** Feld. |
| 684 | 684 | ||
| 685 | **Description:** | 685 | **Beschreibung:** |
| 686 | 686 | ||
| 687 | Whether the compiler should reserve the original comments in the compiled code. | 687 | Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. |
| 688 | 688 | ||
| 689 | **Signature:** | 689 | **Signatur:** |
| 690 | ```lua | 690 | ```lua |
| 691 | reserve_comment: boolean | 691 | reserve_comment: boolean |
| 692 | ``` | 692 | ``` |
| 693 | 693 | ||
| 694 | ### space_over_tab | 694 | ### space_over_tab |
| 695 | 695 | ||
| 696 | **Type:** Field. | 696 | **Typ:** Feld. |
| 697 | 697 | ||
| 698 | **Description:** | 698 | **Beschreibung:** |
| 699 | 699 | ||
| 700 | Whether the compiler should use the space character instead of the tab character in the compiled code. | 700 | Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. |
| 701 | 701 | ||
| 702 | **Signature:** | 702 | **Signatur:** |
| 703 | ```lua | 703 | ```lua |
| 704 | space_over_tab: boolean | 704 | space_over_tab: boolean |
| 705 | ``` | 705 | ``` |
| 706 | 706 | ||
| 707 | ### same_module | 707 | ### same_module |
| 708 | 708 | ||
| 709 | **Type:** Field. | 709 | **Typ:** Feld. |
| 710 | 710 | ||
| 711 | **Description:** | 711 | **Beschreibung:** |
| 712 | 712 | ||
| 713 | Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. | 713 | Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. |
| 714 | 714 | ||
| 715 | **Signature:** | 715 | **Signatur:** |
| 716 | ```lua | 716 | ```lua |
| 717 | same_module: boolean | 717 | same_module: boolean |
| 718 | ``` | 718 | ``` |
| 719 | 719 | ||
| 720 | ### line_offset | 720 | ### line_offset |
| 721 | 721 | ||
| 722 | **Type:** Field. | 722 | **Typ:** Feld. |
| 723 | 723 | ||
| 724 | **Description:** | 724 | **Beschreibung:** |
| 725 | 725 | ||
| 726 | Whether the compiler error message should include the line number offset. For internal use only. | 726 | Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. |
| 727 | 727 | ||
| 728 | **Signature:** | 728 | **Signatur:** |
| 729 | ```lua | 729 | ```lua |
| 730 | line_offset: integer | 730 | line_offset: integer |
| 731 | ``` | 731 | ``` |
| 732 | 732 | ||
| 733 | ### yue.Config.LuaTarget | 733 | ### yue.Config.LuaTarget |
| 734 | 734 | ||
| 735 | **Type:** Enumeration. | 735 | **Typ:** Enumeration. |
| 736 | 736 | ||
| 737 | **Description:** | 737 | **Beschreibung:** |
| 738 | 738 | ||
| 739 | The target Lua version enumeration. | 739 | Die Ziel-Lua-Version. |
| 740 | 740 | ||
| 741 | **Signature:** | 741 | **Signatur:** |
| 742 | ```lua | 742 | ```lua |
| 743 | enum LuaTarget | 743 | enum LuaTarget |
| 744 | "5.1" | 744 | "5.1" |
| @@ -751,71 +751,71 @@ end | |||
| 751 | 751 | ||
| 752 | ### options | 752 | ### options |
| 753 | 753 | ||
| 754 | **Type:** Field. | 754 | **Typ:** Feld. |
| 755 | 755 | ||
| 756 | **Description:** | 756 | **Beschreibung:** |
| 757 | 757 | ||
| 758 | The extra options to be passed to the compilation function. | 758 | Zusätzliche Optionen für die Kompilierung. |
| 759 | 759 | ||
| 760 | **Signature:** | 760 | **Signatur:** |
| 761 | ```lua | 761 | ```lua |
| 762 | options: Options | 762 | options: Options |
| 763 | ``` | 763 | ``` |
| 764 | 764 | ||
| 765 | ## Options | 765 | ## Options |
| 766 | 766 | ||
| 767 | **Description:** | 767 | **Beschreibung:** |
| 768 | 768 | ||
| 769 | The extra compiler options definition. | 769 | Zusätzliche Compiler-Optionen. |
| 770 | 770 | ||
| 771 | ### target | 771 | ### target |
| 772 | 772 | ||
| 773 | **Type:** Field. | 773 | **Typ:** Feld. |
| 774 | 774 | ||
| 775 | **Description:** | 775 | **Beschreibung:** |
| 776 | 776 | ||
| 777 | The target Lua version for the compilation. | 777 | Die Ziel-Lua-Version für die Kompilierung. |
| 778 | 778 | ||
| 779 | **Signature:** | 779 | **Signatur:** |
| 780 | ```lua | 780 | ```lua |
| 781 | target: LuaTarget | 781 | target: LuaTarget |
| 782 | ``` | 782 | ``` |
| 783 | 783 | ||
| 784 | ### path | 784 | ### path |
| 785 | 785 | ||
| 786 | **Type:** Field. | 786 | **Typ:** Feld. |
| 787 | 787 | ||
| 788 | **Description:** | 788 | **Beschreibung:** |
| 789 | 789 | ||
| 790 | The extra module search path. | 790 | Zusätzlicher Modul-Suchpfad. |
| 791 | 791 | ||
| 792 | **Signature:** | 792 | **Signatur:** |
| 793 | ```lua | 793 | ```lua |
| 794 | path: string | 794 | path: string |
| 795 | ``` | 795 | ``` |
| 796 | 796 | ||
| 797 | ### dump_locals | 797 | ### dump_locals |
| 798 | 798 | ||
| 799 | **Type:** Field. | 799 | **Typ:** Feld. |
| 800 | 800 | ||
| 801 | **Description:** | 801 | **Beschreibung:** |
| 802 | 802 | ||
| 803 | Whether to dump the local variables in the traceback error message. Default is false. | 803 | Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. |
| 804 | 804 | ||
| 805 | **Signature:** | 805 | **Signatur:** |
| 806 | ```lua | 806 | ```lua |
| 807 | dump_locals: boolean | 807 | dump_locals: boolean |
| 808 | ``` | 808 | ``` |
| 809 | 809 | ||
| 810 | ### simplified | 810 | ### simplified |
| 811 | 811 | ||
| 812 | **Type:** Field. | 812 | **Typ:** Feld. |
| 813 | 813 | ||
| 814 | **Description:** | 814 | **Beschreibung:** |
| 815 | 815 | ||
| 816 | Whether to simplify the error message. Default is true. | 816 | Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. |
| 817 | 817 | ||
| 818 | **Signature:** | 818 | **Signatur:** |
| 819 | ```lua | 819 | ```lua |
| 820 | simplified: boolean | 820 | simplified: boolean |
| 821 | ``` | 821 | ``` |
