From 1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 6 Feb 2026 11:54:32 +0800 Subject: Updated docs. --- doc/docs/de/doc/advanced/do.md | 16 +- doc/docs/de/doc/advanced/line-decorators.md | 16 +- doc/docs/de/doc/advanced/macro.md | 115 ++-- doc/docs/de/doc/advanced/module.md | 74 +-- doc/docs/de/doc/advanced/try.md | 28 +- doc/docs/de/doc/assignment/assignment.md | 28 +- .../de/doc/assignment/destructuring-assignment.md | 90 +-- doc/docs/de/doc/assignment/if-assignment.md | 35 +- ...ng-clause-controlling-destructive-assignment.md | 36 +- doc/docs/de/doc/assignment/varargs-assignment.md | 4 +- doc/docs/de/doc/control-flow/conditionals.md | 65 +-- doc/docs/de/doc/control-flow/continue.md | 4 +- doc/docs/de/doc/control-flow/for-loop.md | 36 +- doc/docs/de/doc/control-flow/switch.md | 130 ++--- doc/docs/de/doc/control-flow/while-loop.md | 10 +- doc/docs/de/doc/data-structures/comprehensions.md | 74 +-- doc/docs/de/doc/data-structures/table-literals.md | 64 +-- doc/docs/de/doc/functions/backcalls.md | 16 +- doc/docs/de/doc/functions/function-literals.md | 161 +++--- doc/docs/de/doc/functions/function-stubs.md | 32 +- doc/docs/de/doc/getting-started/installation.md | 22 +- doc/docs/de/doc/getting-started/introduction.md | 56 +- doc/docs/de/doc/getting-started/usage.md | 124 ++-- doc/docs/de/doc/language-basics/attributes.md | 12 +- doc/docs/de/doc/language-basics/comment.md | 26 +- doc/docs/de/doc/language-basics/literals.md | 42 +- doc/docs/de/doc/language-basics/operator.md | 143 ++--- doc/docs/de/doc/language-basics/whitespace.md | 12 +- .../de/doc/objects/object-oriented-programming.md | 204 +++---- doc/docs/de/doc/objects/with-statement.md | 43 +- doc/docs/de/doc/reference/license-mit.md | 24 +- doc/docs/de/doc/reference/the-yuescript-library.md | 632 ++++++++++----------- 32 files changed, 1180 insertions(+), 1194 deletions(-) (limited to 'doc/docs/de') 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 @@ # Do -When used as a statement, do works just like it does in Lua. +Als Statement verhält sich `do` wie in Lua. ```yuescript do - var = "hello" + var = "hallo" print var -print var -- nil here +print var -- nil hier ``` ```yue do - var = "hello" + var = "hallo" print var -print var -- nil here +print var -- nil hier ``` -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. +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. ```yuescript counter = do @@ -49,7 +49,7 @@ print counter! ```yuescript tbl = { key: do - print "assigning key!" + print "Schlüssel wird zugewiesen!" 1234 } ``` @@ -58,7 +58,7 @@ tbl = { ```yue tbl = { key: do - print "assigning key!" + print "Schlüssel wird zugewiesen!" 1234 } ``` 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 @@ -# Line Decorators +# Line-Decorators -For convenience, the for loop and if statement can be applied to single statements at the end of the line: +Zur Vereinfachung können `for`-Schleifen und `if`-Anweisungen auf einzelne Anweisungen am Zeilenende angewendet werden: ```yuescript -print "hello world" if name == "Rob" +print "Hallo Welt" if name == "Rob" ``` ```yue -print "hello world" if name == "Rob" +print "Hallo Welt" if name == "Rob" ``` -And with basic loops: +Und mit einfachen Schleifen: ```yuescript -print "item: ", item for item in *items +print "Element: ", item for item in *items ``` ```yue -print "item: ", item for item in *items +print "Element: ", item for item in *items ``` -And with while loops: +Und mit `while`-Schleifen: ```yuescript 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 @@ -# Macro +# Makros -## Common Usage +## Häufige Verwendung -Macro function is used for evaluating a string in the compile time and insert the generated codes into final compilation. +Makrofunktionen werden verwendet, um zur Compile-Zeit einen String auszuwerten und den generierten Code in die finale Kompilierung einzufügen. ```yuescript macro PI2 = -> math.pi * 2 area = $PI2 * 5 -macro HELLO = -> "'hello world'" +macro HELLO = -> "'Hallo Welt'" print $HELLO macro config = (debugging) -> @@ -27,7 +27,7 @@ $asserts item ~= nil $config false value = $assert item --- the passed expressions are treated as strings +-- übergebene Ausdrücke werden als Strings behandelt macro and = (...) -> "#{ table.concat {...}, ' and ' }" if $and f1!, f2!, f3! print "OK" @@ -38,7 +38,7 @@ if $and f1!, f2!, f3! macro PI2 = -> math.pi * 2 area = $PI2 * 5 -macro HELLO = -> "'hello world'" +macro HELLO = -> "'Hallo Welt'" print $HELLO macro config = (debugging) -> @@ -57,7 +57,7 @@ $asserts item ~= nil $config false value = $assert item --- the passed expressions are treated as strings +-- übergebene Ausdrücke werden als Strings behandelt macro and = (...) -> "#{ table.concat {...}, ' and ' }" if $and f1!, f2!, f3! print "OK" @@ -65,31 +65,32 @@ if $and f1!, f2!, f3! -## Insert Raw Codes +## Rohcode einfügen + +Eine Makrofunktion kann entweder einen YueScript-String oder eine Konfigurationstabelle mit Lua-Code zurückgeben. -A macro function can either return a YueScript string or a config table containing Lua codes. ```yuescript macro yueFunc = (var) -> "local #{var} = ->" $yueFunc funcA -funcA = -> "fail to assign to the Yue macro defined variable" +funcA = -> "Zuweisung an die vom Yue-Makro definierte Variable schlägt fehl" macro luaFunc = (var) -> { code: "local function #{var}() end" type: "lua" } $luaFunc funcB -funcB = -> "fail to assign to the Lua macro defined variable" +funcB = -> "Zuweisung an die vom Lua-Makro definierte Variable schlägt fehl" macro lua = (code) -> { :code type: "lua" } --- the raw string leading and ending symbols are auto trimed +-- führende und abschließende Symbole des Raw-Strings werden automatisch getrimmt $lua[==[ --- raw Lua codes insertion +-- Einfügen von rohem Lua-Code if cond then - print("output") + print("Ausgabe") end ]==] ``` @@ -98,63 +99,64 @@ end ```yue macro yueFunc = (var) -> "local #{var} = ->" $yueFunc funcA -funcA = -> "fail to assign to the Yue macro defined variable" +funcA = -> "Zuweisung an die vom Yue-Makro definierte Variable schlägt fehl" macro luaFunc = (var) -> { code: "local function #{var}() end" type: "lua" } $luaFunc funcB -funcB = -> "fail to assign to the Lua macro defined variable" +funcB = -> "Zuweisung an die vom Lua-Makro definierte Variable schlägt fehl" macro lua = (code) -> { :code type: "lua" } --- the raw string leading and ending symbols are auto trimed +-- führende und abschließende Symbole des Raw-Strings werden automatisch getrimmt $lua[==[ --- raw Lua codes insertion +-- Einfügen von rohem Lua-Code if cond then - print("output") + print("Ausgabe") end ]==] ``` -## Export Macro +## Makros exportieren + +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. -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. ```yuescript --- file: utils.yue +-- Datei: utils.yue export macro map = (items, action) -> "[#{action} for _ in *#{items}]" export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" export macro foreach = (items, action) -> "for _ in *#{items} #{action}" --- file main.yue +-- Datei main.yue import "utils" as { - $, -- symbol to import all macros - $foreach: $each -- rename macro $foreach to $each + $, -- Symbol zum Importieren aller Makros + $foreach: $each -- Makro $foreach in $each umbenennen } [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ ``` ```yue --- file: utils.yue +-- Datei: utils.yue export macro map = (items, action) -> "[#{action} for _ in *#{items}]" export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" export macro foreach = (items, action) -> "for _ in *#{items} #{action}" --- file main.yue --- import function is not available in browser, try it in a real environment +-- Datei main.yue +-- Import-Funktion im Browser nicht verfügbar, in echter Umgebung testen --[[ import "utils" as { - $, -- symbol to import all macros - $foreach: $each -- rename macro $foreach to $each + $, -- Symbol zum Importieren aller Makros + $foreach: $each -- Makro $foreach in $each umbenennen } [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ ]] @@ -162,32 +164,33 @@ import "utils" as { -## Builtin Macro +## Eingebaute Makros + +Es gibt einige eingebaute Makros, aber du kannst sie überschreiben, indem du Makros mit denselben Namen deklarierst. -There are some builtin macros but you can override them by declaring macros with the same names. ```yuescript -print $FILE -- get string of current module name -print $LINE -- get number 2 +print $FILE -- String des aktuellen Modulnamens +print $LINE -- gibt 2 aus ``` ```yue -print $FILE -- get string of current module name -print $LINE -- get number 2 +print $FILE -- String des aktuellen Modulnamens +print $LINE -- gibt 2 aus ``` -## Generating Macros with Macros +## Makros mit Makros erzeugen -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. +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. ```yuescript macro Enum = (...) -> items = {...} itemSet = {item, true for item in *items} (item) -> - error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] + error "erhalten: \"#{item}\", erwartet eines von #{table.concat items, ', '}" unless itemSet[item] "\"#{item}\"" macro BodyType = $Enum( @@ -196,8 +199,8 @@ macro BodyType = $Enum( Kinematic ) -print "Valid enum type:", $BodyType Static --- print "Compilation error with enum type:", $BodyType Unknown +print "Gültiger Enum-Typ:", $BodyType Static +-- print "Kompilierungsfehler bei Enum-Typ:", $BodyType Unknown ``` @@ -207,7 +210,7 @@ macro Enum = (...) -> items = {...} itemSet = {item, true for item in *items} (item) -> - error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] + error "erhalten: \"#{item}\", erwartet eines von #{table.concat items, ', '}" unless itemSet[item] "\"#{item}\"" macro BodyType = $Enum( @@ -216,15 +219,15 @@ macro BodyType = $Enum( Kinematic ) -print "Valid enum type:", $BodyType Static --- print "Compilation error with enum type:", $BodyType Unknown +print "Gültiger Enum-Typ:", $BodyType Static +-- print "Kompilierungsfehler bei Enum-Typ:", $BodyType Unknown ``` -## Argument Validation +## Argument-Validierung -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. +Du kannst erwartete AST-Knotentypen in der Argumentliste deklarieren und zur Compile-Zeit prüfen, ob die übergebenen Makroargumente den Erwartungen entsprechen. ```yuescript macro printNumAndStr = (num `Num, str `String) -> | @@ -233,7 +236,7 @@ macro printNumAndStr = (num `Num, str `String) -> | #{str} ) -$printNumAndStr 123, "hello" +$printNumAndStr 123, "hallo" ``` @@ -244,32 +247,32 @@ macro printNumAndStr = (num `Num, str `String) -> | #{str} ) -$printNumAndStr 123, "hello" +$printNumAndStr 123, "hallo" ``` -If you need more flexible argument checking, you can use the built-in `$is_ast` macro function to manually check at the appropriate place. +Wenn du flexiblere Argumentprüfungen brauchst, kannst du das eingebaute Makro `$is_ast` verwenden, um manuell an der passenden Stelle zu prüfen. ```yuescript macro printNumAndStr = (num, str) -> - error "expected Num as first argument" unless $is_ast Num, num - error "expected String as second argument" unless $is_ast String, str + error "als erstes Argument Num erwartet" unless $is_ast Num, num + error "als zweites Argument String erwartet" unless $is_ast String, str "print(#{num}, #{str})" -$printNumAndStr 123, "hello" +$printNumAndStr 123, "hallo" ``` ```yue macro printNumAndStr = (num, str) -> - error "expected Num as first argument" unless $is_ast Num, num - error "expected String as second argument" unless $is_ast String, str + error "als erstes Argument Num erwartet" unless $is_ast Num, num + error "als zweites Argument String erwartet" unless $is_ast String, str "print(#{num}, #{str})" -$printNumAndStr 123, "hello" +$printNumAndStr 123, "hallo" ``` -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). +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 @@ ## Import -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. +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`. ```yuescript --- used as table destructuring +-- als Tabellen-Destrukturierung do import insert, concat from table - -- report error when assigning to insert, concat + -- Fehler beim Zuweisen zu insert, concat import C, Ct, Cmt from require "lpeg" - -- shortcut for implicit requiring + -- Kurzform für implizites Require import x, y, z from 'mymodule' - -- import with Python style + -- Import im Python-Stil from 'module' import a, b, c --- shortcut for requring a module +-- Kurzform zum Laden eines Moduls do import 'module' import 'module_x' import "d-a-s-h-e-s" import "module.part" --- requring module with aliasing or table destructuring +-- Modul mit Alias oder Tabellen-Destrukturierung laden do import "player" as PlayerModule import "lpeg" as :C, :Ct, :Cmt @@ -31,24 +31,24 @@ do ```yue --- used as table destructuring +-- als Tabellen-Destrukturierung do import insert, concat from table - -- report error when assigning to insert, concat + -- Fehler beim Zuweisen zu insert, concat import C, Ct, Cmt from require "lpeg" - -- shortcut for implicit requiring + -- Kurzform für implizites Require import x, y, z from 'mymodule' - -- import with Python style + -- Import im Python-Stil from 'module' import a, b, c --- shortcut for requring a module +-- Kurzform zum Laden eines Moduls do import 'module' import 'module_x' import "d-a-s-h-e-s" import "module.part" --- requring module with aliasing or table destructuring +-- Modul mit Alias oder Tabellen-Destrukturierung laden do import "player" as PlayerModule import "lpeg" as :C, :Ct, :Cmt @@ -57,9 +57,9 @@ do -## Import Global +## Import von Globals -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. +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. ```yuescript do @@ -78,21 +78,21 @@ do -### Automatic Global Variable Import +### Automatischer Global-Import -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. +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. -Names that are explicitly declared as globals in the same scope will not be imported, so you can still assign to them. +Namen, die im selben Scope explizit als `global` deklariert werden, werden nicht importiert, sodass du sie weiterhin zuweisen kannst. ```yuescript do import global - print "hello" + print "hallo" math.random 3 - -- print = nil -- error: imported globals are const + -- print = nil -- Fehler: importierte Globals sind const do - -- explicit global variable will not be imported + -- explizite globale Variable wird nicht importiert import global global FLAG print FLAG @@ -103,12 +103,12 @@ do ```yue do import global - print "hello" + print "hallo" math.random 3 - -- print = nil -- error: imported globals are const + -- print = nil -- Fehler: importierte Globals sind const do - -- explicit global variable will not be imported + -- explizite globale Variable wird nicht importiert import global global FLAG print FLAG @@ -119,15 +119,15 @@ do ## Export -The export statement offers a concise way to define modules. +Die `export`-Anweisung bietet eine knappe Möglichkeit, Module zu definieren. -### Named Export +### Benannter Export -Named export will define a local variable as well as adding a field in the exported table. +Benannter Export definiert eine lokale Variable und fügt ein Feld in die exportierte Tabelle ein. ```yuescript export a, b, c = 1, 2, 3 -export cool = "cat" +export cool = "Katze" export What = if this "abc" @@ -144,7 +144,7 @@ export class Something ```yue export a, b, c = 1, 2, 3 -export cool = "cat" +export cool = "Katze" export What = if this "abc" @@ -160,7 +160,7 @@ export class Something -Doing named export with destructuring. +Benannter Export mit Destructuring. ```yuescript export :loadstring, to_lua: tolua = yue @@ -175,7 +175,7 @@ export {itemA: {:fieldA = 'default'}} = tb -Export named items from module without creating local variables. +Benannte Elemente aus dem Modul exportieren, ohne lokale Variablen zu erstellen. ```yuescript export.itemA = tb @@ -192,9 +192,9 @@ export["a-b-c"] = 123 -### Unnamed Export +### Unbenannter Export -Unnamed export will add the target item into the array part of the exported table. +Unbenannter Export fügt das Ziel-Element in den Array-Teil der exportierten Tabelle ein. ```yuescript d, e, f = 3, 2, 1 @@ -225,20 +225,20 @@ export with tmp -### Default Export +### Default-Export -Using the **default** keyword in export statement to replace the exported table with any thing. +Mit dem Schlüsselwort **default** in einer `export`-Anweisung wird die exportierte Tabelle durch ein beliebiges Objekt ersetzt. ```yuescript export default -> - print "hello" + print "hallo" 123 ``` ```yue export default -> - print "hello" + print "hallo" 123 ``` 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 @@ # Try -The syntax for Lua error handling in a common form. +Die Syntax für Fehlerbehandlung in Lua in einer gängigen Form. ```yuescript try @@ -20,10 +20,10 @@ catch err success, result = try func 1, 2, 3 try - print "trying" + print "Versuche" func 1, 2, 3 --- working with if assignment pattern +-- Verwendung mit if-Zuweisungsmuster if success, result := try func 1, 2, 3 catch err print yue.traceback err @@ -49,10 +49,10 @@ catch err success, result = try func 1, 2, 3 try - print "trying" + print "Versuche" func 1, 2, 3 --- working with if assignment pattern +-- Verwendung mit if-Zuweisungsmuster if success, result := try func 1, 2, 3 catch err print yue.traceback err @@ -63,18 +63,18 @@ catch err ## Try? -`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. +`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. ```yuescript a, b, c = try? func! --- with nil coalescing operator -a = (try? func!) ?? "default" +-- mit Nil-Verschmelzungs-Operator +a = (try? func!) ?? "Standardwert" --- as function argument +-- als Funktionsargument f try? func! --- with catch block +-- mit catch-Block f try? print 123 func! @@ -87,13 +87,13 @@ catch e ```yue a, b, c = try? func! --- with nil coalescing operator -a = (try? func!) ?? "default" +-- mit Nil-Verschmelzungs-Operator +a = (try? func!) ?? "Standardwert" --- as function argument +-- als Funktionsargument f try? func! --- with catch block +-- mit catch-Block f try? print 123 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 @@ -# Assignment +# Zuweisung -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. +Variablen sind dynamisch typisiert und standardmäßig `local`. Du kannst den Geltungsbereich mit den Statements **local** und **global** ändern. ```yuescript hello = "world" a, b, c = 1, 2, 3 -hello = 123 -- uses the existing variable +hello = 123 -- nutzt die bestehende Variable ``` ```yue hello = "world" a, b, c = 1, 2, 3 -hello = 123 -- uses the existing variable +hello = 123 -- nutzt die bestehende Variable ``` -## Perform Update +## Update-Zuweisung + +Du kannst Update-Zuweisungen mit vielen binären Operatoren durchführen. -You can perform update assignment with many binary operators. ```yuescript x = 1 x += 1 @@ -27,7 +28,7 @@ x -= 1 x *= 10 x /= 10 x %= 10 -s ..= "world" -- will add a new local if local variable is not exist +s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert arg or= "default value" ``` @@ -39,15 +40,16 @@ x -= 1 x *= 10 x /= 10 x %= 10 -s ..= "world" -- will add a new local if local variable is not exist +s ..= "world" -- legt eine neue lokale Variable an, wenn sie nicht existiert arg or= "default value" ``` -## Chaining Assignment +## Verkettete Zuweisung + +Mit verketteten Zuweisungen kannst du mehrere Variablen auf denselben Wert setzen. -You can do chaining assignment to assign multiple items to hold the same value. ```yuescript a = b = c = d = e = 0 x = y = z = f! @@ -61,7 +63,8 @@ x = y = z = f! -## Explicit Locals +## Explizite Locals + ```yuescript do local a = 1 @@ -99,7 +102,8 @@ do -## Explicit Globals +## Explizite Globals + ```yuescript do 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 @@ -# Destructuring Assignment +# Destructuring-Zuweisung -Destructuring assignment is a way to quickly extract values from a table by their name or position in array based tables. +Destructuring-Zuweisung ist eine Möglichkeit, schnell Werte aus einer Tabelle nach Name oder Position in array-basierten Tabellen zu extrahieren. -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. +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. -This is best explained with examples. Here is how you would unpack the first two values from a table: +Am besten lässt sich das mit Beispielen erklären. So entpackst du die ersten zwei Werte einer Tabelle: ```yuescript thing = [1, 2] @@ -23,44 +23,44 @@ print a, b -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. +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. ```yuescript obj = { - hello: "world" - day: "tuesday" + hello: "Welt" + day: "Dienstag" length: 20 } {hello: hello, day: the_day} = obj print hello, the_day -:day = obj -- OK to do simple destructuring without braces +:day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok ``` ```yue obj = { - hello: "world" - day: "tuesday" + hello: "Welt" + day: "Dienstag" length: 20 } {hello: hello, day: the_day} = obj print hello, the_day -:day = obj -- OK to do simple destructuring without braces +:day = obj -- einfache Destructuring-Zuweisung ohne Klammern ist ok ``` -This also works with nested data structures as well: +Das funktioniert auch mit verschachtelten Datenstrukturen: ```yuescript obj2 = { numbers: [1, 2, 3, 4] properties: { - color: "green" + color: "grün" height: 13.5 } } @@ -74,7 +74,7 @@ print first, second, color obj2 = { numbers: [1, 2, 3, 4] properties: { - color: "green" + color: "grün" height: 13.5 } } @@ -85,7 +85,7 @@ print first, second, color -If the destructuring statement is complicated, feel free to spread it out over a few lines. A slightly more complicated example: +Wenn die Destructuring-Anweisung kompliziert ist, kannst du sie gerne auf mehrere Zeilen verteilen. Ein etwas komplexeres Beispiel: ```yuescript { @@ -108,7 +108,7 @@ If the destructuring statement is complicated, feel free to spread it out over a -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: +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: ```yuescript {:concat, :insert} = table @@ -121,7 +121,7 @@ It's common to extract values from at table and assign them the local variables -This is effectively the same as import, but we can rename fields we want to extract by mixing the syntax: +Das ist effektiv dasselbe wie `import`, aber du kannst Felder umbenennen, indem du die Syntax mischst: ```yuescript {: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 -You can write default values while doing destructuring like: +Du kannst Standardwerte beim Destructuring angeben, z. B.: ```yuescript -{:name = "nameless", :job = "jobless"} = person +{:name = "namenlos", :job = "arbeitlos"} = person ``` ```yue -{:name = "nameless", :job = "jobless"} = person +{:name = "namenlos", :job = "arbeitlos"} = person ``` -You can use `_` as placeholder when doing a list destructuring: +Du kannst `_` als Platzhalter verwenden, wenn du eine Listen-Destructuring-Zuweisung machst: ```yuescript [_, two, _, four] = items @@ -160,64 +160,64 @@ You can use `_` as placeholder when doing a list destructuring: -## Range Destructuring +## Bereichs-Destructuring -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. +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. ```yuescript -orders = ["first", "second", "third", "fourth", "last"] +orders = ["erster", "zweiter", "dritter", "vierter", "letzter"] [first, ...bulk, last] = orders -print first -- prints: first -print bulk -- prints: {"second", "third", "fourth"} -print last -- prints: last +print first -- gibt aus: erster +print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} +print last -- gibt aus: letzter ``` ```yue -orders = ["first", "second", "third", "fourth", "last"] +orders = ["erster", "zweiter", "dritter", "vierter", "letzter"] [first, ...bulk, last] = orders -print first -- prints: first -print bulk -- prints: {"second", "third", "fourth"} -print last -- prints: last +print first -- gibt aus: erster +print bulk -- gibt aus: {"zweiter", "dritter", "vierter"} +print last -- gibt aus: letzter ``` -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: +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: ```yuescript --- Capture everything after first element +-- Alles nach dem ersten Element erfassen [first, ...rest] = orders --- Capture everything before last element +-- Alles vor dem letzten Element erfassen [...start, last] = orders --- Capture things except the middle elements +-- Alles außer den mittleren Elementen erfassen [first, ..._, last] = orders ``` ```yue --- Capture everything after first element +-- Alles nach dem ersten Element erfassen [first, ...rest] = orders --- Capture everything before last element +-- Alles vor dem letzten Element erfassen [...start, last] = orders --- Capture things except the middle elements +-- Alles außer den mittleren Elementen erfassen [first, ..._, last] = orders ``` -## Destructuring In Other Places +## Destructuring an anderen Stellen -Destructuring can also show up in places where an assignment implicitly takes place. An example of this is a for loop: +Destructuring kann auch an Stellen vorkommen, an denen eine Zuweisung implizit erfolgt. Ein Beispiel ist eine `for`-Schleife: ```yuescript tuples = [ - ["hello", "world"] - ["egg", "head"] + ["hallo", "Welt"] + ["Ei", "Kopf"] ] for [left, right] in *tuples @@ -227,8 +227,8 @@ for [left, right] in *tuples ```yue tuples = [ - ["hello", "world"] - ["egg", "head"] + ["hallo", "Welt"] + ["Ei", "Kopf"] ] for [left, right] in *tuples @@ -237,4 +237,4 @@ for [left, right] in *tuples -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. +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 @@ -# If Assignment +# If-Zuweisung -`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. +`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. ```yuescript if user := database.find_user "moon" @@ -17,55 +17,56 @@ if user := database.find_user "moon" ```yuescript if hello := os.getenv "hello" - print "You have hello", hello + print "Du hast hello", hello elseif world := os.getenv "world" - print "you have world", world + print "Du hast world", world else - print "nothing :(" + print "nichts :(" ``` ```yue if hello := os.getenv "hello" - print "You have hello", hello + print "Du hast hello", hello elseif world := os.getenv "world" - print "you have world", world + print "Du hast world", world else - print "nothing :(" + print "nichts :(" ``` -If assignment with multiple return values. Only the first value is getting checked, other values are scoped. +If-Zuweisung mit mehreren Rückgabewerten. Nur der erste Wert wird geprüft, andere Werte bleiben im Scope. + ```yuescript -if success, result := pcall -> "get result without problems" - print result -- variable result is scoped +if success, result := pcall -> "Ergebnis ohne Probleme erhalten" + print result -- Variable result ist im Scope print "OK" ``` ```yue -if success, result := pcall -> "get result without problems" - print result -- variable result is scoped +if success, result := pcall -> "Ergebnis ohne Probleme erhalten" + print result -- Variable result ist im Scope print "OK" ``` -## While Assignment +## While-Zuweisung -You can also use if assignment in a while loop to get the value as the loop condition. +Du kannst if-Zuweisung auch in einer while-Schleife verwenden, um den Wert als Schleifenbedingung zu nutzen. ```yuescript while byte := stream\read_one! - -- do something with the byte + -- mit dem Byte etwas anfangen print byte ``` ```yue while byte := stream\read_one! - -- do something with the byte + -- mit dem Byte etwas anfangen print byte ``` 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 @@ -# The Using Clause; Controlling Destructive Assignment +# Die Using-Klausel: Destruktive Zuweisung kontrollieren -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: +Lexikalisches Scoping kann die Komplexität des Codes stark reduzieren, aber mit wachsendem Codeumfang kann es unübersichtlich werden. Betrachte folgendes Beispiel: ```yuescript i = 100 --- many lines of code... +-- viele Zeilen Code... my_func = -> i = 10 @@ -15,14 +15,14 @@ my_func = -> my_func! -print i -- will print 0 +print i -- wird 0 ausgeben ``` ```yue i = 100 --- many lines of code... +-- viele Zeilen Code... my_func = -> i = 10 @@ -32,25 +32,25 @@ my_func = -> my_func! -print i -- will print 0 +print i -- wird 0 ausgeben ``` -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. +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. -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. +Es wäre hilfreich, anzugeben, welche Variablen aus dem umschließenden Scope wir verändern wollen, um versehentliche Änderungen zu vermeiden. -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. +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. ```yuescript i = 100 my_func = (using nil) -> - i = "hello" -- a new local variable is created here + i = "hello" -- hier wird eine neue lokale Variable erstellt my_func! -print i -- prints 100, i is unaffected +print i -- gibt 100 aus, i bleibt unverändert ``` @@ -58,27 +58,27 @@ print i -- prints 100, i is unaffected i = 100 my_func = (using nil) -> - i = "hello" -- a new local variable is created here + i = "hello" -- hier wird eine neue lokale Variable erstellt my_func! -print i -- prints 100, i is unaffected +print i -- gibt 100 aus, i bleibt unverändert ``` -Multiple names can be separated by commas. Closure values can still be accessed, they just cant be modified: +Mehrere Namen können durch Kommas getrennt werden. Closure-Werte können weiterhin gelesen, aber nicht verändert werden: ```yuescript tmp = 1213 i, k = 100, 50 my_func = (add using k, i) -> - tmp = tmp + add -- a new local tmp is created + tmp = tmp + add -- ein neues lokales tmp wird erstellt i += tmp k += tmp my_func(22) -print i, k -- these have been updated +print i, k -- diese wurden aktualisiert ``` @@ -87,12 +87,12 @@ tmp = 1213 i, k = 100, 50 my_func = (add using k, i) -> - tmp = tmp + add -- a new local tmp is created + tmp = tmp + add -- ein neues lokales tmp wird erstellt i += tmp k += tmp my_func(22) -print i, k -- these have been updated +print i, k -- diese wurden aktualisiert ``` 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 @@ -# Varargs Assignment +# Varargs-Zuweisung -You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. +Du kannst Rückgabewerte einer Funktion dem Varargs-Symbol `...` zuweisen und dann den Inhalt auf die Lua-Weise auslesen. ```yuescript 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 @@ -# Conditionals +# Bedingungen ```yuescript have_coins = false if have_coins - print "Got coins" + print "Münzen erhalten" else - print "No coins" + print "Keine Münzen" ``` ```yue have_coins = false if have_coins - print "Got coins" + print "Münzen erhalten" else - print "No coins" + print "Keine Münzen" ``` -A short syntax for single statements can also be used: +Eine Kurzsyntax für einzelne Anweisungen kann ebenfalls verwendet werden: ```yuescript have_coins = false -if have_coins then print "Got coins" else print "No coins" +if have_coins then print "Münzen erhalten" else print "Keine Münzen" ``` ```yue have_coins = false -if have_coins then print "Got coins" else print "No coins" +if have_coins then print "Münzen erhalten" else print "Keine Münzen" ``` -Because if statements can be used as expressions, this can also be written as: +Da `if`-Anweisungen als Ausdrücke verwendet werden können, kann man das auch so schreiben: ```yuescript have_coins = false -print if have_coins then "Got coins" else "No coins" +print if have_coins then "Münzen erhalten" else "Keine Münzen" ``` ```yue have_coins = false -print if have_coins then "Got coins" else "No coins" +print if have_coins then "Münzen erhalten" else "Keine Münzen" ``` -Conditionals can also be used in return statements and assignments: +Bedingungen können auch in `return`-Anweisungen und Zuweisungen verwendet werden: ```yuescript is_tall = (name) -> @@ -59,11 +59,11 @@ is_tall = (name) -> false message = if is_tall "Rob" - "I am very tall" + "Ich bin sehr groß" else - "I am not so tall" + "Ich bin nicht so groß" -print message -- prints: I am very tall +print message -- gibt aus: Ich bin sehr groß ``` @@ -75,26 +75,26 @@ is_tall = (name) -> false message = if is_tall "Rob" - "I am very tall" + "Ich bin sehr groß" else - "I am not so tall" + "Ich bin nicht so groß" -print message -- prints: I am very tall +print message -- gibt aus: Ich bin sehr groß ``` -The opposite of if is unless: +Das Gegenteil von `if` ist `unless`: ```yuescript unless os.date("%A") == "Monday" - print "it is not Monday!" + print "Es ist nicht Montag!" ``` ```yue unless os.date("%A") == "Monday" - print "it is not Monday!" + print "Es ist nicht Montag!" ``` @@ -110,18 +110,18 @@ print "You're lucky!" unless math.random! > 0.1 -## In Expression +## In-Ausdruck -You can write range checking code with an `in-expression`. +Mit einem `in`-Ausdruck kannst du Bereichsprüfungen schreiben. ```yuescript a = 5 if a in [1, 3, 5, 7] - print "checking equality with discrete values" + print "Gleichheitsprüfung mit diskreten Werten" if a in list - print "checking if `a` is in a list" + print "Prüfen, ob `a` in einer Liste ist" ``` @@ -129,21 +129,10 @@ if a in list a = 5 if a in [1, 3, 5, 7] - print "checking equality with discrete values" + print "Gleichheitsprüfung mit diskreten Werten" if a in list - print "checking if `a` is in a list" -``` - - - -```yuescript -print "You're lucky!" unless math.random! > 0.1 -``` - - -```yue -print "You're lucky!" unless math.random! > 0.1 + print "Prüfen, ob `a` in einer Liste ist" ``` 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 @@ # Continue -A continue statement can be used to skip the current iteration in a loop. +Eine `continue`-Anweisung überspringt die aktuelle Iteration einer Schleife. ```yuescript i = 0 @@ -21,7 +21,7 @@ while i < 10 -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: +`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: ```yuescript 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 @@ -# For Loop +# For-Schleife -There are two for loop forms, just like in Lua. A numeric one and a generic one: +Es gibt zwei Formen der `for`-Schleife, genau wie in Lua: eine numerische und eine generische. ```yuescript for i = 10, 20 print i -for k = 1, 15, 2 -- an optional step provided +for k = 1, 15, 2 -- ein optionaler Schritt print k for key, value in pairs object @@ -18,7 +18,7 @@ for key, value in pairs object for i = 10, 20 print i -for k = 1, 15, 2 -- an optional step provided +for k = 1, 15, 2 -- ein optionaler Schritt print k for key, value in pairs object @@ -27,7 +27,7 @@ for key, value in pairs object -The slicing and **\*** operators can be used, just like with comprehensions: +Die Slicing- und **\***-Operatoren können verwendet werden, genau wie bei Comprehensions: ```yuescript for item in *items[2, 4] @@ -42,7 +42,7 @@ for item in *items[2, 4] -A shorter syntax is also available for all variations when the body is only a single line: +Eine kürzere Syntax ist für alle Varianten verfügbar, wenn der Rumpf nur eine Zeile hat: ```yuescript for item in *items do print item @@ -59,9 +59,9 @@ for j = 1, 10, 3 do print j -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. +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. -Doubling every even number: +Alle geraden Zahlen verdoppeln: ```yuescript doubled_evens = for i = 1, 20 @@ -82,9 +82,9 @@ doubled_evens = for i = 1, 20 -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. +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. -For example, to find the first number greater than 10: +Beispiel: die erste Zahl größer als 10 finden: ```yuescript first_large = for n in *numbers @@ -99,18 +99,18 @@ first_large = for n in *numbers -This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. +Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken. -You can also filter values by combining the for loop expression with the continue statement. +Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst. -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. +`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. ```yuescript func_a = -> for i = 1, 10 do print i func_b = -> return for i = 1, 10 do i -print func_a! -- prints nil -print func_b! -- prints table object +print func_a! -- gibt nil aus +print func_b! -- gibt Tabellenobjekt aus ``` @@ -118,10 +118,10 @@ print func_b! -- prints table object func_a = -> for i = 1, 10 do print i func_b = -> return for i = 1, 10 do i -print func_a! -- prints nil -print func_b! -- prints table object +print func_a! -- gibt nil aus +print func_b! -- gibt Tabellenobjekt aus ``` -This is done to avoid the needless creation of tables for functions that don't need to return the results of the loop. +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 @@ # Switch -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. +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. ```yuescript switch name := "Dan" when "Robert" - print "You are Robert" + print "Du bist Robert" when "Dan", "Daniel" - print "Your name, it's Dan" + print "Dein Name ist Dan" else - print "I don't know about you with name #{name}" + print "Ich kenne dich nicht mit dem Namen #{name}" ``` ```yue switch name := "Dan" when "Robert" - print "You are Robert" + print "Du bist Robert" when "Dan", "Daniel" - print "Your name, it's Dan" + print "Dein Name ist Dan" else - print "I don't know about you with name #{name}" + print "Ich kenne dich nicht mit dem Namen #{name}" ``` -A switch when clause can match against multiple values by listing them out comma separated. +Eine `when`-Klausel kann mehrere Werte prüfen, indem sie kommasepariert aufgelistet werden. -Switches can be used as expressions as well, here we can assign the result of the switch to a variable: +`switch` kann auch als Ausdruck verwendet werden. Hier wird das Ergebnis der `switch`-Anweisung einer Variable zugewiesen: ```yuescript b = 1 @@ -37,7 +37,7 @@ next_number = switch b when 2 3 else - error "can't count that high!" + error "so hoch kann ich nicht zählen!" ``` @@ -49,66 +49,66 @@ next_number = switch b when 2 3 else - error "can't count that high!" + error "so hoch kann ich nicht zählen!" ``` -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. +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. ```yuescript msg = switch math.random(1, 5) - when 1 then "you are lucky" - when 2 then "you are almost lucky" - else "not so lucky" + when 1 then "Du hast Glück" + when 2 then "Du hast fast Glück" + else "nicht so viel Glück" ``` ```yue msg = switch math.random(1, 5) - when 1 then "you are lucky" - when 2 then "you are almost lucky" - else "not so lucky" + when 1 then "Du hast Glück" + when 2 then "Du hast fast Glück" + else "nicht so viel Glück" ``` -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. +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. ```yuescript switch math.random(1, 5) when 1 - print "you are lucky" -- two indents + print "Du hast Glück" -- zwei Einrückungen else - print "not so lucky" + print "nicht so viel Glück" switch math.random(1, 5) when 1 - print "you are lucky" -- one indent + print "Du hast Glück" -- eine Einrückung else - print "not so lucky" + print "nicht so viel Glück" ``` ```yue switch math.random(1, 5) when 1 - print "you are lucky" -- two indents + print "Du hast Glück" -- zwei Einrückungen else - print "not so lucky" + print "nicht so viel Glück" switch math.random(1, 5) when 1 - print "you are lucky" -- one indent + print "Du hast Glück" -- eine Einrückung else - print "not so lucky" + print "nicht so viel Glück" ``` -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. +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. -## Table Matching +## Tabellen-Matching -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. +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. ```yuescript items = @@ -122,7 +122,7 @@ for item in *items when :x, :y print "Vec2 #{x}, #{y}" when :width, :height - print "size #{width}, #{height}" + print "Größe #{width}, #{height}" ``` @@ -138,39 +138,39 @@ for item in *items when :x, :y print "Vec2 #{x}, #{y}" when :width, :height - print "size #{width}, #{height}" + print "Größe #{width}, #{height}" ``` -You can use default values to optionally destructure the table for some fields. +Du kannst Standardwerte verwenden, um bestimmte Felder optional zu destrukturieren. ```yuescript item = {} -{pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') +{pos: {:x = 50, :y = 200}} = item -- Fehler: Versuch, einen nil-Wert zu indexieren (Feld 'pos') switch item when {pos: {:x = 50, :y = 200}} - print "Vec2 #{x}, #{y}" -- table destructuring will still pass + print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem ``` ```yue item = {} -{pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') +{pos: {:x = 50, :y = 200}} = item -- Fehler: Versuch, einen nil-Wert zu indexieren (Feld 'pos') switch item when {pos: {:x = 50, :y = 200}} - print "Vec2 #{x}, #{y}" -- table destructuring will still pass + print "Vec2 #{x}, #{y}" -- Tabellen-Destrukturierung greift trotzdem ``` -You can also match against array elements, table fields, and even nested structures with array or table literals. +Du kannst auch gegen Array-Elemente, Tabellenfelder und sogar verschachtelte Strukturen mit Array- oder Tabellenliteralen matchen. -Match against array elements. +Matchen gegen Array-Elemente. ```yuescript switch tb @@ -178,7 +178,7 @@ switch tb print "1, 2, 3" when [1, b, 3] print "1, #{b}, 3" - when [1, 2, b = 3] -- b has a default value + when [1, 2, b = 3] -- b hat einen Standardwert print "1, 2, #{b}" ``` @@ -189,63 +189,63 @@ switch tb print "1, 2, 3" when [1, b, 3] print "1, #{b}, 3" - when [1, 2, b = 3] -- b has a default value + when [1, 2, b = 3] -- b hat einen Standardwert print "1, 2, #{b}" ``` -Match against table fields with destructuring. +Matchen gegen Tabellenfelder mit Destructuring. ```yuescript switch tb when success: true, :result - print "success", result + print "Erfolg", result when success: false - print "failed", result + print "fehlgeschlagen", result else - print "invalid" + print "ungültig" ``` ```yue switch tb when success: true, :result - print "success", result + print "Erfolg", result when success: false - print "failed", result + print "fehlgeschlagen", result else - print "invalid" + print "ungültig" ``` -Match against nested table structures. +Matchen gegen verschachtelte Tabellenstrukturen. ```yuescript switch tb when data: {type: "success", :content} - print "success", content + print "Erfolg", content when data: {type: "error", :content} - print "failed", content + print "fehlgeschlagen", content else - print "invalid" + print "ungültig" ``` ```yue switch tb when data: {type: "success", :content} - print "success", content + print "Erfolg", content when data: {type: "error", :content} - print "failed", content + print "fehlgeschlagen", content else - print "invalid" + print "ungültig" ``` -Match against array of tables. +Matchen gegen Array von Tabellen. ```yuescript switch tb @@ -255,7 +255,7 @@ switch tb {a: 5, b: 6} fourth ] - print "matched", fourth + print "getroffen", fourth ``` @@ -267,20 +267,20 @@ switch tb {a: 5, b: 6} fourth ] - print "matched", fourth + print "getroffen", fourth ``` -Match against a list and capture a range of elements. +Matchen gegen eine Liste und einen Bereich von Elementen erfassen. ```yuescript segments = ["admin", "users", "logs", "view"] switch segments when [...groups, resource, action] - print "Group:", groups -- prints: {"admin", "users"} - print "Resource:", resource -- prints: "logs" - print "Action:", action -- prints: "view" + print "Gruppe:", groups -- gibt aus: {"admin", "users"} + print "Ressource:", resource -- gibt aus: "logs" + print "Aktion:", action -- gibt aus: "view" ``` @@ -288,9 +288,9 @@ switch segments segments = ["admin", "users", "logs", "view"] switch segments when [...groups, resource, action] - print "Group:", groups -- prints: {"admin", "users"} - print "Resource:", resource -- prints: "logs" - print "Action:", action -- prints: "view" + print "Gruppe:", groups -- gibt aus: {"admin", "users"} + print "Ressource:", resource -- gibt aus: "logs" + print "Aktion:", action -- gibt aus: "view" ``` 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 @@ -# While Loop +# While-Schleife -The while loop also comes in four variations: +Die `while`-Schleife gibt es ebenfalls in vier Variationen: ```yuescript i = 10 @@ -43,11 +43,11 @@ until running == false do my_function! -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. +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. -## Repeat Loop +## Repeat-Schleife -The repeat loop comes from Lua: +Die `repeat`-Schleife stammt aus Lua: ```yuescript 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 @@ # Comprehensions -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. +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. -## List Comprehensions +## Listen-Comprehensions -The following creates a copy of the items table but with all the values doubled. +Das folgende Beispiel erstellt eine Kopie der `items`-Tabelle, aber mit verdoppelten Werten. ```yuescript items = [ 1, 2, 3, 4 ] @@ -19,7 +19,7 @@ doubled = [item * 2 for i, item in ipairs items] -The items included in the new table can be restricted with a when clause: +Die Elemente in der neuen Tabelle können mit einer `when`-Klausel eingeschränkt werden: ```yuescript 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] -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: +Da es üblich ist, über die Werte einer numerisch indizierten Tabelle zu iterieren, gibt es den **\***-Operator. Das Verdopplungsbeispiel kann so umgeschrieben werden: ```yuescript doubled = [item * 2 for item in *items] @@ -45,7 +45,7 @@ doubled = [item * 2 for item in *items] -In list comprehensions, you can also use the spread operator `...` to flatten nested lists, achieving a flat map effect: +In Listen-Comprehensions kannst du außerdem den Spread-Operator `...` verwenden, um verschachtelte Listen zu flatten und einen Flat-Map-Effekt zu erzielen: ```yuescript data = @@ -53,7 +53,7 @@ data = b: [4, 5, 6] flat = [...v for k,v in pairs data] --- flat is now [1, 2, 3, 4, 5, 6] +-- flat ist jetzt [1, 2, 3, 4, 5, 6] ``` @@ -63,14 +63,14 @@ data = b: [4, 5, 6] flat = [...v for k,v in pairs data] --- flat is now [1, 2, 3, 4, 5, 6] +-- flat ist jetzt [1, 2, 3, 4, 5, 6] ``` -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. +Die `for`- und `when`-Klauseln können beliebig oft verkettet werden. Die einzige Anforderung ist, dass eine Comprehension mindestens eine `for`-Klausel enthält. -Using multiple for clauses is the same as using nested loops: +Mehrere `for`-Klauseln entsprechen verschachtelten Schleifen: ```yuescript x_coords = [4, 5, 6, 7] @@ -91,7 +91,7 @@ for y in *y_coords] -Numeric for loops can also be used in comprehensions: +Numerische `for`-Schleifen können ebenfalls in Comprehensions verwendet werden: ```yuescript evens = [i for i = 1, 100 when i % 2 == 0] @@ -104,16 +104,16 @@ evens = [i for i = 1, 100 when i % 2 == 0] -## Table Comprehensions +## Tabellen-Comprehensions -The syntax for table comprehensions is very similar, only differing by using **{** and **}** and taking two values from each iteration. +Die Syntax für Tabellen-Comprehensions ist sehr ähnlich, unterscheidet sich jedoch dadurch, dass **{** und **}** verwendet werden und pro Iteration zwei Werte erzeugt werden. -This example makes a copy of the tablething: +Dieses Beispiel erstellt eine Kopie von `thing`: ```yuescript thing = { - color: "red" - name: "fast" + color: "rot" + name: "schnell" width: 123 } @@ -123,8 +123,8 @@ thing_copy = {k, v for k, v in pairs thing} ```yue thing = { - color: "red" - name: "fast" + color: "rot" + name: "schnell" width: 123 } @@ -144,7 +144,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} -The **\*** operator is also supported. Here we create a square root look up table for a few numbers. +Der **\***-Operator wird ebenfalls unterstützt. Hier erstellen wir eine Nachschlagetabelle für Quadratwurzeln einiger Zahlen. ```yuescript numbers = [1, 2, 3, 4] @@ -159,18 +159,18 @@ sqrts = {i, math.sqrt i for i in *numbers} -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: +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: -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. +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. ```yuescript -tuples = [ ["hello", "world"], ["foo", "bar"]] +tuples = [ ["hallo", "Welt"], ["foo", "bar"]] tbl = {unpack tuple for tuple in *tuples} ``` ```yue -tuples = [ ["hello", "world"], ["foo", "bar"]] +tuples = [ ["hallo", "Welt"], ["foo", "bar"]] tbl = {unpack tuple for tuple in *tuples} ``` @@ -178,9 +178,9 @@ tbl = {unpack tuple for tuple in *tuples} ## Slicing -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. +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. -Here we can set the minimum and maximum bounds, taking all items with indexes between 1 and 5 inclusive: +Hier setzen wir die minimalen und maximalen Grenzen und nehmen alle Elemente mit Indizes zwischen 1 und 5 (inklusive): ```yuescript slice = [item for item in *items[1, 5]] @@ -193,7 +193,7 @@ slice = [item for item in *items[1, 5]] -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: +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: ```yuescript slice = [item for item in *items[2,]] @@ -206,7 +206,7 @@ slice = [item for item in *items[2,]] -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, …) +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, …): ```yuescript slice = [item for item in *items[,,2]] @@ -219,22 +219,22 @@ slice = [item for item in *items[,,2]] -Both the minimum and maximum bounds can be negative, which means that the bounds are counted from the end of the table. +Sowohl die Mindest- als auch die Maximalgrenze können negativ sein; dann werden die Grenzen vom Ende der Tabelle gezählt. ```yuescript --- take the last 4 items +-- die letzten 4 Elemente nehmen slice = [item for item in *items[-4,-1]] ``` ```yue --- take the last 4 items +-- die letzten 4 Elemente nehmen slice = [item for item in *items[-4,-1]] ``` -The step size can also be negative, which means that the items are taken in reverse order. +Die Schrittweite kann ebenfalls negativ sein, wodurch die Elemente in umgekehrter Reihenfolge genommen werden. ```yuescript reverse_slice = [item for item in *items[-1,1,-1]] @@ -247,24 +247,24 @@ reverse_slice = [item for item in *items[-1,1,-1]] -### Slicing Expression +### Slicing-Ausdruck -Slicing can also be used as an expression. This is useful for getting a sub-list of a table. +Slicing kann auch als Ausdruck verwendet werden. Das ist nützlich, um eine Teilliste einer Tabelle zu erhalten. ```yuescript --- take the 2nd and 4th items as a new list +-- das 2. und 4. Element als neue Liste nehmen sub_list = items[2, 4] --- take the last 4 items +-- die letzten 4 Elemente nehmen last_four_items = items[-4, -1] ``` ```yue --- take the 2nd and 4th items as a new list +-- das 2. und 4. Element als neue Liste nehmen sub_list = items[2, 4] --- take the last 4 items +-- die letzten 4 Elemente nehmen last_four_items = items[-4, -1] ``` 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 @@ -# Table Literals +# Tabellenliterale -Like in Lua, tables are delimited in curly braces. +Wie in Lua werden Tabellen mit geschweiften Klammern definiert. ```yuescript some_values = [1, 2, 3, 4] @@ -13,13 +13,13 @@ some_values = [1, 2, 3, 4] -Unlike Lua, assigning a value to a key in a table is done with **:** (instead of **=**). +Anders als in Lua weist man einem Schlüssel in einer Tabelle mit **:** (statt **=**) einen Wert zu. ```yuescript some_values = { name: "Bill", age: 200, - ["favorite food"]: "rice" + ["Lieblingsessen"]: "Reis" } ``` @@ -28,39 +28,39 @@ some_values = { some_values = { name: "Bill", age: 200, - ["favorite food"]: "rice" + ["Lieblingsessen"]: "Reis" } ``` -The curly braces can be left off if a single table of key value pairs is being assigned. +Die geschweiften Klammern können weggelassen werden, wenn eine einzelne Tabelle aus Schlüssel-Wert-Paaren zugewiesen wird. ```yuescript profile = - height: "4 feet", + height: "4 Fuß", shoe_size: 13, - favorite_foods: ["ice cream", "donuts"] + favorite_foods: ["Eis", "Donuts"] ``` ```yue profile = - height: "4 feet", + height: "4 Fuß", shoe_size: 13, - favorite_foods: ["ice cream", "donuts"] + favorite_foods: ["Eis", "Donuts"] ``` -Newlines can be used to delimit values instead of a comma (or both): +Zeilenumbrüche können Werte statt eines Kommas trennen (oder zusätzlich): ```yuescript values = { 1, 2, 3, 4 5, 6, 7, 8 - name: "superman" - occupation: "crime fighting" + name: "Superman" + occupation: "Verbrechensbekämpfung" } ``` @@ -69,50 +69,50 @@ values = { values = { 1, 2, 3, 4 5, 6, 7, 8 - name: "superman" - occupation: "crime fighting" + name: "Superman" + occupation: "Verbrechensbekämpfung" } ``` -When creating a single line table literal, the curly braces can also be left off: +Beim Erstellen eines einzeiligen Tabellenliterals können die geschweiften Klammern ebenfalls weggelassen werden: ```yuescript -my_function dance: "Tango", partner: "none" +my_function dance: "Tango", partner: "keiner" -y = type: "dog", legs: 4, tails: 1 +y = type: "Hund", legs: 4, tails: 1 ``` ```yue -my_function dance: "Tango", partner: "none" +my_function dance: "Tango", partner: "keiner" -y = type: "dog", legs: 4, tails: 1 +y = type: "Hund", legs: 4, tails: 1 ``` -The keys of a table literal can be language keywords without being escaped: +Die Schlüssel eines Tabellenliterals können Sprach-Schlüsselwörter sein, ohne sie zu escapen: ```yuescript tbl = { - do: "something" - end: "hunger" + do: "etwas" + end: "Hunger" } ``` ```yue tbl = { - do: "something" - end: "hunger" + do: "etwas" + end: "Hunger" } ``` -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: +Wenn du eine Tabelle aus Variablen konstruierst und die Schlüssel den Variablennamen entsprechen sollen, kannst du den Präfix-Operator **:** verwenden: ```yuescript hair = "golden" @@ -133,26 +133,26 @@ print_table :hair, :height -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. +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. ```yuescript t = { - [1 + 2]: "hello" - "hello world": true + [1 + 2]: "hallo" + "Hallo Welt": true } ``` ```yue t = { - [1 + 2]: "hello" - "hello world": true + [1 + 2]: "hallo" + "Hallo Welt": true } ``` -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. +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. ```yuescript 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 @@ # Backcalls -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. +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. ```yuescript x <- f -print "hello" .. x +print "hallo" .. x ``` ```yue x <- f -print "hello" .. x +print "hallo" .. x ``` -Fat arrow functions are also available. +Fat-Arrow-Funktionen sind ebenfalls verfügbar. ```yuescript <= f @@ -30,7 +30,7 @@ print @value -You can specify a placeholder for where you want the backcall function to go as a parameter. +Du kannst einen Platzhalter angeben, an welcher Stelle die Backcall-Funktion als Parameter eingesetzt werden soll. ```yuescript (x) <- map _, [1, 2, 3] @@ -45,11 +45,11 @@ x * 2 -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. +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. ```yuescript result, msg = do - data <- readAsync "filename.txt" + data <- readAsync "dateiname.txt" print data info <- processAsync data check info @@ -59,7 +59,7 @@ print result, msg ```yue result, msg = do - data <- readAsync "filename.txt" + data <- readAsync "dateiname.txt" print data info <- processAsync data 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 @@ -# Function Literals +# Funktionsliterale -All functions are created using a function expression. A simple function is denoted using the arrow: **->**. +Alle Funktionen werden mit einem Funktionsausdruck erstellt. Eine einfache Funktion wird mit dem Pfeil **->** notiert. ```yuescript my_function = -> -my_function() -- call the empty function +my_function() -- leere Funktion aufrufen ``` ```yue my_function = -> -my_function() -- call the empty function +my_function() -- leere Funktion aufrufen ``` -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: +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: ```yuescript -func_a = -> print "hello world" +func_a = -> print "Hallo Welt" func_b = -> value = 100 - print "The value:", value + print "Der Wert:", value ``` ```yue -func_a = -> print "hello world" +func_a = -> print "Hallo Welt" func_b = -> value = 100 - print "The value:", value + print "Der Wert:", value ``` -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. +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. ```yuescript func_a! @@ -51,20 +51,20 @@ func_b() -Functions with arguments can be created by preceding the arrow with a list of argument names in parentheses: +Funktionen mit Argumenten werden erstellt, indem der Pfeil von einer Argumentliste in Klammern eingeleitet wird: ```yuescript -sum = (x, y) -> print "sum", x + y +sum = (x, y) -> print "Summe", x + y ``` ```yue -sum = (x, y) -> print "sum", x + y +sum = (x, y) -> print "Summe", x + y ``` -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. +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. ```yuescript sum 10, 20 @@ -83,7 +83,7 @@ a b c "a", "b", "c" -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. +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. ```yuescript print "x:", sum(10, 20), "y:", sum(30, 40) @@ -96,24 +96,24 @@ print "x:", sum(10, 20), "y:", sum(30, 40) -There must not be any space between the opening parenthesis and the function. +Zwischen öffnender Klammer und Funktionsname darf kein Leerzeichen stehen. -Functions will coerce the last statement in their body into a return statement, this is called implicit return: +Funktionen wandeln die letzte Anweisung im Funktionskörper in ein `return` um. Das nennt sich implizites Return: ```yuescript sum = (x, y) -> x + y -print "The sum is ", sum 10, 20 +print "Die Summe ist ", sum 10, 20 ``` ```yue sum = (x, y) -> x + y -print "The sum is ", sum 10, 20 +print "Die Summe ist ", sum 10, 20 ``` -And if you need to explicitly return, you can use the return keyword: +Wenn du explizit zurückgeben willst, verwende `return`: ```yuescript sum = (x, y) -> return x + y @@ -126,7 +126,7 @@ sum = (x, y) -> return x + y -Just like in Lua, functions can return multiple values. The last statement must be a list of values separated by commas: +Wie in Lua können Funktionen mehrere Werte zurückgeben. Die letzte Anweisung muss eine Liste von Werten sein, getrennt durch Kommas: ```yuescript mystery = (x, y) -> x + y, x - y @@ -143,7 +143,7 @@ a, b = mystery 10, 20 ## Fat Arrows -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. +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. ```yuescript func = (num) => @value + num @@ -156,26 +156,26 @@ func = (num) => @value + num -## Argument Defaults +## Standardwerte für Argumente -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. +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. ```yuescript -my_function = (name = "something", height = 100) -> - print "Hello I am", name - print "My height is", height +my_function = (name = "etwas", height = 100) -> + print "Hallo, ich bin", name + print "Meine Größe ist", height ``` ```yue -my_function = (name = "something", height = 100) -> - print "Hello I am", name - print "My height is", height +my_function = (name = "etwas", height = 100) -> + print "Hallo, ich bin", name + print "Meine Größe ist", height ``` -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. +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. ```yuescript some_args = (x = 100, y = x + 1000) -> @@ -190,11 +190,11 @@ some_args = (x = 100, y = x + 1000) -> -## Considerations +## Hinweise -Because of the expressive parentheses-less way of calling functions, some restrictions must be put in place to avoid parsing ambiguity involving whitespace. +Aufgrund der ausdrucksstarken, klammerlosen Funktionsaufrufe müssen einige Einschränkungen gelten, um Parsing-Mehrdeutigkeiten mit Leerraum zu vermeiden. -The minus sign plays two roles, a unary negation operator and a binary subtraction operator. Consider how the following examples compile: +Das Minuszeichen hat zwei Rollen: unäre Negation und binäre Subtraktion. Sieh dir an, wie die folgenden Beispiele kompiliert werden: ```yuescript a = x - 10 @@ -213,30 +213,30 @@ d = x- z -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. +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. -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. +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. -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. +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. ```yuescript -x = func"hello" + 100 -y = func "hello" + 100 +x = func"hallo" + 100 +y = func "hallo" + 100 ``` ```yue -x = func"hello" + 100 -y = func "hello" + 100 +x = func"hallo" + 100 +y = func "hallo" + 100 ``` -## Multi-line arguments +## Mehrzeilige Argumente -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. +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. -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 +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. ```yuescript my_func 5, 4, 3, @@ -261,7 +261,7 @@ cool_func 1, 2, -This type of invocation can be nested. The level of indentation is used to determine to which function the arguments belong to. +Diese Art des Aufrufs kann verschachtelt werden. Die Einrückungsebene bestimmt, zu welcher Funktion die Argumente gehören. ```yuescript my_func 5, 6, 7, @@ -280,7 +280,7 @@ my_func 5, 6, 7, -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. +Da Tabellen ebenfalls das Komma als Trennzeichen verwenden, hilft diese Einrückungssyntax dabei, Werte zur Argumentliste gehören zu lassen, statt zur Tabelle. ```yuescript x = [ @@ -301,7 +301,7 @@ x = [ -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. +Obwohl es selten ist: Du kannst Funktionsargumente tiefer einrücken, wenn du weißt, dass du später eine geringere Einrückungsebene verwenden wirst. ```yuescript y = [ my_func 1, 2, 3, @@ -320,46 +320,45 @@ y = [ my_func 1, 2, 3, -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: +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: ```yuescript if func 1, 2, 3, - "hello", - "world" - print "hello" - print "I am inside if" + "hallo", + "Welt" + print "hallo" + print "Ich bin innerhalb der if-Bedingung" if func 1, 2, 3, - "hello", - "world" - print "hello" - print "I am inside if" + "hallo", + "Welt" + print "hallo" + print "Ich bin innerhalb der if-Bedingung" ``` ```yue if func 1, 2, 3, - "hello", - "world" - print "hello" - print "I am inside if" + "hallo", + "Welt" + print "hallo" + print "Ich bin innerhalb der if-Bedingung" if func 1, 2, 3, - "hello", - "world" - print "hello" - print "I am inside if" + "hallo", + "Welt" + print "hallo" + print "Ich bin innerhalb der if-Bedingung" ``` -## Parameter Destructuring +## Parameter-Destructuring -YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available: +YueScript unterstützt jetzt Destructuring von Funktionsparametern, wenn das Argument ein Objekt ist. Es gibt zwei Formen von Destructuring-Tabellenliteralen: -* **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`). - -* **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. +* **Geschweifte Klammern/Objektparameter**, die optionale Standardwerte erlauben, wenn Felder fehlen (z. B. `{:a, :b}`, `{a: a1 = 123}`). +* **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. ```yuescript f1 = (:a, :b, :c) -> @@ -390,9 +389,9 @@ f2 arg1, arg2 -## Prefixed Return Expression +## Präfixiertes Return-Expression -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: +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: ```yuescript findFirstEven = (list): nil -> @@ -415,7 +414,7 @@ findFirstEven = (list): nil -> -This is equivalent to: +Das ist äquivalent zu: ```yuescript findFirstEven = (list) -> @@ -440,16 +439,16 @@ findFirstEven = (list) -> -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. +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. -## Named Varargs +## Benannte Varargs -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). +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). ```yuescript f = (...t) -> - print "argument count:", t.n - print "table length:", #t + print "Anzahl der Argumente:", t.n + print "Tabellenlänge:", #t for i = 1, t.n print t[i] @@ -457,7 +456,7 @@ f 1, 2, 3 f "a", "b", "c", "d" f! --- Handling cases with nil values +-- Fälle mit nil-Werten behandeln process = (...args) -> sum = 0 for i = 1, args.n @@ -471,8 +470,8 @@ process 1, nil, 3, nil, 5 ```yue f = (...t) -> - print "argument count:", t.n - print "table length:", #t + print "Anzahl der Argumente:", t.n + print "Tabellenlänge:", #t for i = 1, t.n print t[i] @@ -480,7 +479,7 @@ f 1, 2, 3 f "a", "b", "c", "d" f! --- Handling cases with nil values +-- Fälle mit nil-Werten behandeln process = (...args) -> sum = 0 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 @@ -# Function Stubs +# Funktions-Stubs -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. +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. -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. +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. -Its syntax is the same as calling an instance method with the \ operator but with no argument list provided. +Die Syntax entspricht dem Aufruf einer Instanzmethode mit dem `\`-Operator, jedoch ohne Argumentliste. ```yuescript my_object = { value: 1000 - write: => print "the value:", @value + write: => print "der Wert:", @value } run_callback = (func) -> - print "running callback..." + print "Callback wird ausgeführt..." func! --- this will not work: --- the function has to no reference to my_object +-- das funktioniert nicht: +-- die Funktion darf keine Referenz auf my_object haben run_callback my_object.write --- function stub syntax --- lets us bundle the object into a new function +-- Funktions-Stub-Syntax +-- bindet das Objekt in eine neue Funktion ein run_callback my_object\write ``` @@ -29,19 +29,19 @@ run_callback my_object\write ```yue my_object = { value: 1000 - write: => print "the value:", @value + write: => print "der Wert:", @value } run_callback = (func) -> - print "running callback..." + print "Callback wird ausgeführt..." func! --- this will not work: --- the function has to no reference to my_object +-- das funktioniert nicht: +-- die Funktion darf keine Referenz auf my_object haben run_callback my_object.write --- function stub syntax --- lets us bundle the object into a new function +-- Funktions-Stub-Syntax +-- bindet das Objekt in eine neue Funktion ein run_callback my_object\write ``` 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 @@ # Installation -## Lua Module +## Lua-Modul -Install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module and executable with: +Installiere [luarocks](https://luarocks.org), einen Paketmanager für Lua-Module. Installiere YueScript dann als Lua-Modul und ausführbare Datei mit: ```shell luarocks install yuescript ``` -Or you can build `yue.so` file with: +Oder du kannst die Datei `yue.so` bauen mit: ```shell make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua ``` -Then get the binary file from path **bin/shared/yue.so**. +Anschließend findest du die Binärdatei unter **bin/shared/yue.so**. -## Build Binary Tool +## Binär-Tool bauen -Clone this repo, then build and install executable with: +Klone dieses Repo und baue/installiere die ausführbare Datei mit: ```shell make install ``` -Build YueScript tool without macro feature: +YueScript-Tool ohne Makro-Feature bauen: ```shell make install NO_MACRO=true ``` -Build YueScript tool without built-in Lua binary: +YueScript-Tool ohne eingebautes Lua-Binary bauen: ```shell make install NO_LUA=true ``` -## Download Precompiled Binary +## Vorgefertigtes Binary herunterladen -You can download precompiled binary files, including binary executable files compatible with different Lua versions and library files. +Du kannst vorkompilierte Binärdateien herunterladen, inklusive ausführbarer Dateien für unterschiedliche Lua-Versionen und Bibliotheksdateien. -Download precompiled binary files from [here](https://github.com/IppClub/YueScript/releases). +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 @@ -# Introduction +# Einführung -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. +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. -Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ]. +Yue (月) ist das chinesische Wort für Mond und wird als [jyɛ] ausgesprochen. -## An Overview of YueScript +## Ein Überblick über YueScript ```yuescript --- import syntax +-- Import-Syntax import p, to_lua from "yue" --- object literals +-- Objekt-Literale inventory = equipment: - - "sword" - - "shield" + - "Schwert" + - "Schild" items: - - name: "potion" + - name: "Trank" count: 10 - - name: "bread" + - name: "Brot" count: 3 --- list comprehension +-- Listen-Abstraktion map = (arr, action) -> [action item for item in *arr] @@ -31,14 +31,14 @@ filter = (arr, cond) -> reduce = (arr, init, action): init -> init = action init, item for item in *arr --- pipe operator +-- Pipe-Operator [1, 2, 3] |> map (x) -> x * 2 |> filter (x) -> x > 4 |> reduce 0, (a, b) -> a + b |> print --- metatable manipulation +-- Metatable-Manipulation apple = size: 15 : @@ -47,28 +47,28 @@ apple = with apple p .size, .color, . if .<>? --- js-like export syntax -export 🌛 = "月之脚本" +-- export-Syntax (ähnlich wie in JavaScript) +export 🌛 = "Skript des Mondes" ``` ```yue --- import syntax +-- Import-Syntax import p, to_lua from "yue" --- object literals +-- Objekt-Literale inventory = equipment: - - "sword" - - "shield" + - "Schwert" + - "Schild" items: - - name: "potion" + - name: "Trank" count: 10 - - name: "bread" + - name: "Brot" count: 3 --- list comprehension +-- Listen-Abstraktion map = (arr, action) -> [action item for item in *arr] @@ -78,14 +78,14 @@ filter = (arr, cond) -> reduce = (arr, init, action): init -> init = action init, item for item in *arr --- pipe operator +-- Pipe-Operator [1, 2, 3] |> map (x) -> x * 2 |> filter (x) -> x > 4 |> reduce 0, (a, b) -> a + b |> print --- metatable manipulation +-- Metatable-Manipulation apple = size: 15 : @@ -94,12 +94,12 @@ apple = with apple p .size, .color, . if .<>? --- js-like export syntax -export 🌛 = "月之脚本" +-- export-Syntax (ähnlich wie in JavaScript) +export 🌛 = "Skript des Mondes" ``` -## About Dora SSR +## Über Dora SSR -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 +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 @@ -# Usage +# Verwendung -## Lua Module +## Lua-Modul -Use YueScript module in Lua: +YueScript-Modul in Lua verwenden: -* **Case 1** +* **Fall 1** - Require "your_yuescript_entry.yue" in Lua. + "your_yuescript_entry.yue" in Lua require'n. ```Lua require("yue")("your_yuescript_entry") ``` - 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. + 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. -* **Case 2** +* **Fall 2** - Require YueScript module and rewite message by hand. + YueScript-Modul require'n und das Fehlermapping manuell umschreiben. ```lua local yue = require("yue") @@ -26,15 +26,15 @@ Use YueScript module in Lua: end) ``` -* **Case 3** +* **Fall 3** - Use the YueScript compiler function in Lua. + Die YueScript-Compilerfunktion in Lua verwenden. ```lua local yue = require("yue") local codes, err, globals = yue.to_lua([[ f = -> - print "hello world" + print "Hallo Welt" f! ]],{ implicit_return_root = true, @@ -48,64 +48,66 @@ Use YueScript module in Lua: }) ``` -## YueScript Tool +## YueScript-Tool -Use YueScript tool with: +YueScript-Tool verwenden mit: ```shell > yue -h -Usage: yue - [options] [] ... - yue -e [args...] - yue -w [] [options] - yue - - -Notes: - - '-' / '--' must be the first and only argument. - - '-o/--output' can not be used with multiple input files. - - '-w/--watch' can not be used with file input (directory only). - - with '-e/--execute', remaining tokens are treated as script args. - -Options: - -h, --help Show this help message and exit. - -e , --execute Execute a file or raw codes - -m, --minify Generate minified codes - -r, --rewrite Rewrite output to match original line numbers - -t , --output-to - Specify where to place compiled files - -o , --output Write output to file - -p, --print Write output to standard out - -b, --benchmark Dump compile time (doesn't write output) - -g, --globals Dump global variables used in NAME LINE COLUMN - -s, --spaces Use spaces in generated codes instead of tabs - -l, --line-numbers Write line numbers from source codes - -j, --no-implicit-return Disable implicit return at end of file - -c, --reserve-comments Reserve comments before statement from source codes - -w [], --watch [] - Watch changes and compile every file under directory - -v, --version Print version - - Read from standard in, print to standard out - (Must be first and only argument) - -- Same as '-' (kept for backward compatibility) - - --target Specify the Lua version that codes will be generated to - (version can only be 5.1 to 5.5) - --path Append an extra Lua search path string to package.path - --= Pass compiler option in key=value form (existing behavior) - - Execute without options to enter REPL, type symbol '$' - in a single line to start/stop multi-line mode +Verwendung: yue + [Optionen] [] ... + yue -e [argumente...] + yue -w [] [optionen] + yue - + +Hinweise: + - '-' / '--' muss das erste und einzige Argument sein. + - '-o/--output' kann nicht mit mehreren Eingabedateien verwendet werden. + - '-w/--watch' kann nicht mit Dateieingabe verwendet werden (nur Verzeichnisse). + - Mit '-e/--execute' werden verbleibende Tokens als Skriptargumente behandelt. + +Optionen: + -h, --help Zeigt diese Hilfemeldung an und beendet das Programm. + -e , --execute Datei oder Quellcode ausführen + -m, --minify Minimierten Code erzeugen + -r, --rewrite Ausgabe so umschreiben, dass die Zeilennummern dem Original entsprechen + -t , --output-to + Ziel für kompilierte Dateien angeben + -o , --output + Schreibe die Ausgabe in eine Datei + -p, --print Schreibe die Ausgabe auf die Standardausgabe + -b, --benchmark Gibt die Kompilierungszeit aus (keine Ausgabe schreiben) + -g, --globals Gibt verwendete globale Variablen im Format NAME ZEILE SPALTE aus + -s, --spaces Verwende Leerzeichen anstelle von Tabs im generierten Code + -l, --line-numbers Schreibe Zeilennummern aus dem Quellcode + -j, --no-implicit-return Deaktiviert implizites Rückgabe am Datei-Ende + -c, --reserve-comments Kommentare aus dem Quellcode vor Anweisungen beibehalten + -w [], --watch [] + Änderungen beobachten und alle Dateien im Verzeichnis kompilieren + -v, --version Version ausgeben + - Lese von Standardinput, schreibe auf Standardausgabe + (muss das erste und einzige Argument sein) + -- Wie '-', bleibt zur Abwärtskompatibilität bestehen + + --target Gib an, welche Lua-Version erzeugt werden soll + (Version nur von 5.1 bis 5.5 möglich) + --path Füge einen zusätzlichen Lua-Suchpfad zu package.path hinzu + --= Übertrage Compileroption im Schlüssel=Wert-Format (bestehendes Verhalten) + + Ohne Optionen wird die REPL gestartet, gebe das Symbol '$' + in eine einzelne Zeile ein, um den Multi-Line-Modus zu starten/beenden ``` -Use cases: -Recursively compile every YueScript file with extension **.yue** under current path: **yue .** +Anwendungsfälle: -Compile and save results to a target path: **yue -t /target/path/ .** +Rekursiv jede YueScript-Datei mit der Endung **.yue** unter dem aktuellen Pfad kompilieren: **yue .** -Compile and reserve debug info: **yue -l .** +Kompilieren und Ergebnisse in einen Zielpfad schreiben: **yue -t /target/path/ .** -Compile and generate minified codes: **yue -m .** +Kompilieren und Debug-Infos beibehalten: **yue -l .** -Execute raw codes: **yue -e 'print 123'** +Kompilieren und minifizierten Code erzeugen: **yue -m .** -Execute a YueScript file: **yue -e main.yue** +Rohcode ausführen: **yue -e 'print 123'** + +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 @@ -# Attributes +# Attribute -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. +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. ```yuescript const a = 123 -close _ = : -> print "Out of scope." +close _ = : -> print "Außerhalb des Gültigkeitsbereichs." ``` ```yue const a = 123 -close _ = : -> print "Out of scope." +close _ = : -> print "Außerhalb des Gültigkeitsbereichs." ``` -You can do desctructuring with variables attributed as constant. +Du kannst Destructuring mit als konstant markierten Variablen verwenden. ```yuescript const {:a, :b, c, d} = tb @@ -30,7 +30,7 @@ const {:a, :b, c, d} = tb -You can also declare a global variable to be `const`. +Du kannst auch eine globale Variable als `const` deklarieren. ```yuescript 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 @@ -# Comment +# Kommentare ```yuescript --- I am a comment +-- Ich bin ein Kommentar str = --[[ -This is a multi-line comment. -It's OK. -]] strA \ -- comment 1 - .. strB \ -- comment 2 +Dies ist ein mehrzeiliger Kommentar. +Alles okay. +]] strA \ -- Kommentar 1 + .. strB \ -- Kommentar 2 .. strC -func --[[port]] 3000, --[[ip]] "192.168.1.1" +func --[[Port]] 3000, --[[IP]] "192.168.1.1" ``` ```yue --- I am a comment +-- Ich bin ein Kommentar str = --[[ -This is a multi-line comment. -It's OK. -]] strA \ -- comment 1 - .. strB \ -- comment 2 +Dies ist ein mehrzeiliger Kommentar. +Alles okay. +]] strA \ -- Kommentar 1 + .. strB \ -- Kommentar 2 .. strC -func --[[port]] 3000, --[[ip]] "192.168.1.1" +func --[[Port]] 3000, --[[IP]] "192.168.1.1" ``` 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 @@ -# Literals +# Literale -All of the primitive literals in Lua can be used. This applies to numbers, strings, booleans, and **nil**. +Alle primitiven Literale in Lua können verwendet werden. Das gilt für Zahlen, Strings, Booleans und **nil**. -Unlike Lua, Line breaks are allowed inside of single and double quote strings without an escape sequence: +Anders als in Lua sind Zeilenumbrüche innerhalb einfacher und doppelter Anführungszeichen ohne Escape-Sequenz erlaubt: ```yuescript -some_string = "Here is a string - that has a line break in it." +some_string = "Hier ist ein String + mit einem Zeilenumbruch." --- You can mix expressions into string literals using #{} syntax. --- String interpolation is only available in double quoted strings. -print "I am #{math.random! * 100}% sure." +-- Mit der #{}-Syntax kannst du Ausdrücke in String-Literale einbinden. +-- String-Interpolation gibt es nur in doppelt angeführten Strings. +print "Ich bin mir zu #{math.random! * 100}% sicher." ``` ```yue -some_string = "Here is a string - that has a line break in it." +some_string = "Hier ist ein String + mit einem Zeilenumbruch." --- You can mix expressions into string literals using #{} syntax. --- String interpolation is only available in double quoted strings. -print "I am #{math.random! * 100}% sure." +-- Mit der #{}-Syntax kannst du Ausdrücke in String-Literale einbinden. +-- String-Interpolation gibt es nur in doppelt angeführten Strings. +print "Ich bin mir zu #{math.random! * 100}% sicher." ``` -## Number Literals +## Zahlenliterale -You can use underscores in a number literal to increase readability. +Du kannst Unterstriche in Zahlenliteralen verwenden, um die Lesbarkeit zu erhöhen. ```yuescript integer = 1_000_000 @@ -44,9 +44,9 @@ binary = 0B10011 -## YAML Multiline String +## YAML-Mehrzeilen-String -The `|` prefix introduces a YAML-style multiline string literal: +Das Präfix `|` führt ein mehrzeiliges String-Literal im YAML-Stil ein: ```yuescript str = | @@ -67,9 +67,9 @@ str = | -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)`. +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. -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. +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. ```yuescript fn = -> @@ -90,9 +90,9 @@ fn = -> -Internal indentation is preserved relative to the removed common prefix, allowing clean nested structures. +Die interne Einrückung bleibt relativ zum entfernten gemeinsamen Präfix erhalten, wodurch saubere, verschachtelte Strukturen möglich sind. -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. +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. ```yuescript 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 @@ -# Operator +# Operatoren -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. +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. ```yuescript tb\func! if tb ~= nil @@ -15,32 +15,32 @@ tb::func! if tb != nil -## Chaining Comparisons +## Verkettete Vergleiche -Comparisons can be arbitrarily chained: +Vergleiche können beliebig verkettet werden: ```yuescript print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 --- output: true +-- Ausgabe: true a = 5 print 1 <= a <= 10 --- output: true +-- Ausgabe: true ``` ```yue print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 --- output: true +-- Ausgabe: true a = 5 print 1 <= a <= 10 --- output: true +-- Ausgabe: true ``` -Note the evaluation behavior of chained comparisons: +Beachte das Auswertungsverhalten verketteter Vergleiche: ```yuescript v = (x) -> @@ -49,7 +49,7 @@ v = (x) -> print v(1) < v(2) <= v(3) --[[ - output: + Ausgabe: 2 1 3 @@ -58,7 +58,7 @@ print v(1) < v(2) <= v(3) print v(1) > v(2) <= v(3) --[[ - output: + Ausgabe: 2 1 false @@ -73,7 +73,7 @@ v = (x) -> print v(1) < v(2) <= v(3) --[[ - output: + Ausgabe: 2 1 3 @@ -82,7 +82,7 @@ print v(1) < v(2) <= v(3) print v(1) > v(2) <= v(3) --[[ - output: + Ausgabe: 2 1 false @@ -91,32 +91,32 @@ print v(1) > v(2) <= v(3) -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. +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. -## Table Appending +## Tabellenerweiterung -The **[] =** operator is used to append values to tables. +Der Operator **[] =** wird verwendet, um Werte an Tabellen anzuhängen. ```yuescript tab = [] -tab[] = "Value" +tab[] = "Wert" ``` ```yue tab = [] -tab[] = "Value" +tab[] = "Wert" ``` -You can also use the spread operator `...` to append all elements from one list to another: +Du kannst auch den Spread-Operator `...` verwenden, um alle Elemente einer Liste an eine andere anzuhängen: ```yuescript tbA = [1, 2, 3] tbB = [4, 5, 6] tbA[] = ...tbB --- tbA is now [1, 2, 3, 4, 5, 6] +-- tbA ist jetzt [1, 2, 3, 4, 5, 6] ``` @@ -124,24 +124,24 @@ tbA[] = ...tbB tbA = [1, 2, 3] tbB = [4, 5, 6] tbA[] = ...tbB --- tbA is now [1, 2, 3, 4, 5, 6] +-- tbA ist jetzt [1, 2, 3, 4, 5, 6] ``` -## Table Spreading +## Tabellen-Spread -You can concatenate array tables or hash tables using spread operator `...` before expressions in table literals. +Du kannst Array-Tabellen oder Hash-Tabellen mit dem Spread-Operator `...` vor Ausdrücken in Tabellenliteralen zusammenführen. ```yuescript parts = - * "shoulders" - * "knees" + * "Schultern" + * "Knie" lyrics = - * "head" + * "Kopf" * ...parts - * "and" - * "toes" + * "und" + * "Zehen" copy = {...other} @@ -153,13 +153,13 @@ merge = {...a, ...b} ```yue parts = - * "shoulders" - * "knees" + * "Schultern" + * "Knie" lyrics = - * "head" + * "Kopf" * ...parts - * "and" - * "toes" + * "und" + * "Zehen" copy = {...other} @@ -170,9 +170,9 @@ merge = {...a, ...b} -## Table Reversed Indexing +## Umgekehrter Tabellenindex -You can use the **#** operator to get the last elements of a table. +Mit dem Operator **#** kannst du auf die letzten Elemente einer Tabelle zugreifen. ```yuescript last = data.items[#] @@ -191,11 +191,11 @@ data.items[#] = 1 ## Metatable -The **<>** operator can be used as a shortcut for metatable manipulation. +Der Operator **<>** kann als Abkürzung für Metatable-Manipulation verwendet werden. -### Metatable Creation +### Metatable erstellen -Create normal table with empty bracekets **<>** or metamethod key which is surrounded by **<>**. +Erzeuge eine normale Tabelle mit leeren Klammern **<>** oder einem Metamethod-Schlüssel, der von **<>** umschlossen ist. ```yuescript mt = {} @@ -203,14 +203,14 @@ add = (right) => <>: mt, value: @value + right.value mt.__add = add a = <>: mt, value: 1 - -- set field with variable of the same name + -- Feld mit gleichnamiger Variable setzen b = :, value: 2 c = : mt.__add, value: 3 d = a + b + c print d.value -close _ = : -> print "out of scope" +close _ = : -> print "Außerhalb des Gültigkeitsbereichs" ``` @@ -220,47 +220,47 @@ add = (right) => <>: mt, value: @value + right.value mt.__add = add a = <>: mt, value: 1 - -- set field with variable of the same name + -- Feld mit gleichnamiger Variable setzen b = :, value: 2 c = : mt.__add, value: 3 d = a + b + c print d.value -close _ = : -> print "out of scope" +close _ = : -> print "Außerhalb des Gültigkeitsbereichs" ``` -### Metatable Accessing +### Metatable-Zugriff -Accessing metatable with **<>** or metamethod name surrounded by **<>** or writing some expression in **<>**. +Metatable mit **<>** oder einem von **<>** umschlossenen Metamethod-Namen aufrufen oder einen Ausdruck in **<>** schreiben. ```yuescript --- create with metatable containing field "value" +-- erstellen mit Metatable, das das Feld "value" enthält tb = <"value">: 123 tb. = tb.<> print tb.value -tb.<> = __index: {item: "hello"} +tb.<> = __index: {item: "hallo"} print tb.item ``` ```yue --- create with metatable containing field "value" +-- erstellen mit Metatable, das das Feld "value" enthält tb = <"value">: 123 tb. = tb.<> print tb.value -tb.<> = __index: {item: "hello"} +tb.<> = __index: {item: "hallo"} print tb.item ``` -### Metatable Destructure +### Metatable-Destrukturierung -Destruct metatable with metamethod key surrounded by **<>**. +Destrukturiere Metatable mit Metamethoden-Schlüssel, der von **<>** umschlossen ist. ```yuescript {item, :new, :, : getter} = tb @@ -275,9 +275,9 @@ print item, new, close, getter -## Existence +## Existenz -The **?** operator can be used in a variety of contexts to check for existence. +Der Operator **?** kann in verschiedenen Kontexten verwendet werden, um die Existenz zu prüfen. ```yuescript func?! @@ -314,14 +314,14 @@ with? io.open "test.txt", "w" ## Piping -Instead of a series of nested function calls, you can pipe values with operator **|>**. +Anstelle einer Reihe verschachtelter Funktionsaufrufe kannst du Werte mit dem Operator **|>** weiterleiten. ```yuescript "hello" |> print -1 |> print 2 -- insert pipe item as the first argument -2 |> print 1, _, 3 -- pipe with a placeholder +1 |> print 2 -- Pipe-Element als erstes Argument einfügen +2 |> print 1, _, 3 -- Pipe mit Platzhalter --- pipe expression in multiline +-- Pipe-Ausdruck über mehrere Zeilen readFile "example.txt" |> extract language, {} |> parse language @@ -333,9 +333,9 @@ readFile "example.txt" ```yue "hello" |> print -1 |> print 2 -- insert pipe item as the first argument -2 |> print 1, _, 3 -- pipe with a placeholder --- pipe expression in multiline +1 |> print 2 -- Pipe-Element als erstes Argument einfügen +2 |> print 1, _, 3 -- Pipe mit Platzhalter +-- Pipe-Ausdruck über mehrere Zeilen readFile "example.txt" |> extract language, {} |> parse language @@ -346,9 +346,10 @@ readFile "example.txt" -## Nil Coalescing +## Nil-Coalescing + +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. -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. ```yuescript local a, b, c, d a = b ?? c ?? d @@ -367,31 +368,31 @@ a ??= false -## Implicit Object +## Implizites Objekt -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. +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. ```yuescript --- assignment with implicit object +-- Zuweisung mit implizitem Objekt list = * 1 * 2 * 3 --- function call with implicit object +-- Funktionsaufruf mit implizitem Objekt func * 1 * 2 * 3 --- return with implicit object +-- Rückgabe mit implizitem Objekt f = -> return * 1 * 2 * 3 --- table with implicit object +-- Tabelle mit implizitem Objekt tb = name: "abc" @@ -416,26 +417,26 @@ tb = ```yue --- assignment with implicit object +-- Zuweisung mit implizitem Objekt list = * 1 * 2 * 3 --- function call with implicit object +-- Funktionsaufruf mit implizitem Objekt func * 1 * 2 * 3 --- return with implicit object +-- Rückgabe mit implizitem Objekt f = -> return * 1 * 2 * 3 --- table with implicit object +-- Tabelle mit implizitem Objekt tb = name: "abc" 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 @@ -# Whitespace +# Leerraum -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. +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. -## Statement Separator +## Anweisungs-Trenner -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: +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: ```yuescript a = 1; b = 2; print a + b @@ -17,9 +17,9 @@ a = 1; b = 2; print a + b -## Multiline Chaining +## Mehrzeiliges Chaining -You can write multi-line chaining function calls with a same indent. +Du kannst mehrzeilige, verkettete Funktionsaufrufe mit derselben Einrückung schreiben. ```yuescript 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 @@ -# Object Oriented Programming +# Objektorientierte Programmierung -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. +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. -A simple class: +Eine einfache Klasse: ```yuescript class Inventory @@ -31,36 +31,36 @@ class Inventory -A class is declared with a class statement followed by a table-like declaration where all of the methods and properties are listed. +Eine Klasse wird mit einem `class`-Statement deklariert, gefolgt von einer tabellenähnlichen Deklaration mit allen Methoden und Eigenschaften. -The new property is special in that it will become the constructor. +Die Eigenschaft `new` ist besonders, da sie zum Konstruktor wird. -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. +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. -The @ prefix on a variable name is shorthand for self.. @items becomes self.items. +Das `@`-Präfix ist Kurzform für `self.`. `@items` wird zu `self.items`. -Creating an instance of the class is done by calling the name of the class as a function. +Eine Instanz der Klasse wird erstellt, indem man den Klassennamen wie eine Funktion aufruft. ```yuescript inv = Inventory! -inv\add_item "t-shirt" -inv\add_item "pants" +inv\add_item "T-Shirt" +inv\add_item "Hose" ``` ```yue inv = Inventory! -inv\add_item "t-shirt" -inv\add_item "pants" +inv\add_item "T-Shirt" +inv\add_item "Hose" ``` -Because the instance of the class needs to be sent to the methods when they are called, the \ operator is used. +Da die Instanz bei Methodenaufrufen an die Methoden übergeben werden muss, wird der `\`-Operator verwendet. -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. +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. -Consider the example below, the clothes property is shared amongst all instances, so modifications to it in one instance will show up in another: +Im folgenden Beispiel wird die Eigenschaft `clothes` von allen Instanzen geteilt, sodass Änderungen in einer Instanz in einer anderen sichtbar werden: ```yuescript class Person @@ -71,10 +71,10 @@ class Person a = Person! b = Person! -a\give_item "pants" -b\give_item "shirt" +a\give_item "Hose" +b\give_item "Hemd" --- will print both pants and shirt +-- gibt sowohl Hose als auch Hemd aus print item for item in *a.clothes ``` @@ -88,16 +88,16 @@ class Person a = Person! b = Person! -a\give_item "pants" -b\give_item "shirt" +a\give_item "Hose" +b\give_item "Hemd" --- will print both pants and shirt +-- gibt sowohl Hose als auch Hemd aus print item for item in *a.clothes ``` -The proper way to avoid this problem is to create the mutable state of the object in the constructor: +Der richtige Weg, das zu vermeiden, ist, den veränderlichen Zustand im Konstruktor zu erstellen: ```yuescript class Person @@ -114,15 +114,15 @@ class Person -## Inheritance +## Vererbung -The extends keyword can be used in a class declaration to inherit the properties and methods from another class. +Das Schlüsselwort `extends` kann in einer Klassendeklaration verwendet werden, um Eigenschaften und Methoden von einer anderen Klasse zu erben. ```yuescript class BackPack extends Inventory size: 10 add_item: (name) => - if #@items > size then error "backpack is full" + if #@items > size then error "Rucksack ist voll" super name ``` @@ -131,24 +131,24 @@ class BackPack extends Inventory class BackPack extends Inventory size: 10 add_item: (name) => - if #@items > size then error "backpack is full" + if #@items > size then error "Rucksack ist voll" super name ``` -Here we extend our Inventory class, and limit the amount of items it can carry. +Hier erweitern wir unsere `Inventory`-Klasse und begrenzen die Anzahl der Elemente. -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. +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. -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. +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. ```yuescript class Shelf @__inherited: (child) => - print @__name, "was inherited by", child.__name + print @__name, "wurde vererbt von", child.__name --- will print: Shelf was inherited by Cupboard +-- gibt aus: Shelf wurde von Cupboard geerbt class Cupboard extends Shelf ``` @@ -156,9 +156,9 @@ class Cupboard extends Shelf ```yue class Shelf @__inherited: (child) => - print @__name, "was inherited by", child.__name + print @__name, "wurde vererbt von", child.__name --- will print: Shelf was inherited by Cupboard +-- gibt aus: Shelf wurde von Cupboard geerbt class Cupboard extends Shelf ``` @@ -166,27 +166,27 @@ class Cupboard extends Shelf ## Super -**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. +**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. -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) +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). -When super is used as a normal value, it is a reference to the parent class object. +Wenn `super` als normaler Wert verwendet wird, ist es eine Referenz auf das Objekt der Elternklasse. -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. +Du kannst es wie jedes andere Objekt verwenden, um Werte der Elternklasse zu lesen, die von der Kindklasse überschattet wurden. -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. +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. -A few examples of using super in different ways: +Ein paar Beispiele für `super` in unterschiedlichen Formen: ```yuescript class MyClass extends ParentClass a_method: => - -- the following have the same effect: - super "hello", "world" - super\a_method "hello", "world" - super.a_method self, "hello", "world" + -- Folgendes hat dieselbe Wirkung: + super "hallo", "Welt" + super\a_method "hallo", "Welt" + super.a_method self, "hallo", "Welt" - -- super as a value is equal to the parent class: + -- super als Wert entspricht der Elternklasse: assert super == ParentClass ``` @@ -194,28 +194,28 @@ class MyClass extends ParentClass ```yue class MyClass extends ParentClass a_method: => - -- the following have the same effect: - super "hello", "world" - super\a_method "hello", "world" - super.a_method self, "hello", "world" + -- Folgendes hat dieselbe Wirkung: + super "hallo", "Welt" + super\a_method "hallo", "Welt" + super.a_method self, "hallo", "Welt" - -- super as a value is equal to the parent class: + -- super als Wert entspricht der Elternklasse: assert super == ParentClass ``` -**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. +**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. -## Types +## Typen -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. +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. ```yuescript b = BackPack! assert b.__class == BackPack -print BackPack.size -- prints 10 +print BackPack.size -- gibt 10 aus ``` @@ -223,70 +223,70 @@ print BackPack.size -- prints 10 b = BackPack! assert b.__class == BackPack -print BackPack.size -- prints 10 +print BackPack.size -- gibt 10 aus ``` -## Class Objects +## Klassenobjekte -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. +Das Klassenobjekt entsteht, wenn wir ein `class`-Statement verwenden. Es wird in einer Variablen mit dem Klassennamen gespeichert. -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. +Das Klassenobjekt kann wie eine Funktion aufgerufen werden, um neue Instanzen zu erstellen. So haben wir die Instanzen in den Beispielen oben erstellt. -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. +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. -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. +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. -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. +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. -The class object has a couple special properties: +Das Klassenobjekt hat einige spezielle Eigenschaften: -The name of the class as when it was declared is stored as a string in the __name field of the class object. +Der Name der Klasse, wie sie deklariert wurde, wird im Feld `__name` gespeichert. ```yuescript -print BackPack.__name -- prints Backpack +print BackPack.__name -- gibt Backpack aus ``` ```yue -print BackPack.__name -- prints Backpack +print BackPack.__name -- gibt Backpack aus ``` -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. +Die Basistabelle ist in `__base` gespeichert. Du kannst diese Tabelle ändern, um Instanzen Funktionalität hinzuzufügen, die bereits existieren oder noch erstellt werden. -If the class extends from anything, the parent class object is stored in __parent. +Wenn die Klasse von etwas erbt, ist das Elternklassenobjekt in `__parent` gespeichert. -## Class Variables +## Klassenvariablen -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. +Du kannst Variablen direkt im Klassenobjekt statt in der Basis erstellen, indem du in der Klassendeklaration `@` vor den Eigenschaftsnamen setzt. ```yuescript class Things - @some_func: => print "Hello from", @__name + @some_func: => print "Hallo von", @__name Things\some_func! --- class variables not visible in instances +-- Klassenvariablen in Instanzen nicht sichtbar assert Things().some_func == nil ``` ```yue class Things - @some_func: => print "Hello from", @__name + @some_func: => print "Hallo von", @__name Things\some_func! --- class variables not visible in instances +-- Klassenvariablen in Instanzen nicht sichtbar assert Things().some_func == nil ``` -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. +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`. ```yuescript class Counter @@ -298,7 +298,7 @@ class Counter Counter! Counter! -print Counter.count -- prints 2 +print Counter.count -- gibt 2 aus ``` @@ -312,12 +312,12 @@ class Counter Counter! Counter! -print Counter.count -- prints 2 +print Counter.count -- gibt 2 aus ``` -The calling semantics of @@ are similar to @. Calling a @@ name will pass the class in as the first argument using Lua's colon syntax. +Die Aufrufsemantik von `@@` ist ähnlich wie bei `@`. Wenn du einen `@@`-Namen aufrufst, wird die Klasse als erstes Argument übergeben (Lua-`:`-Syntax). ```yuescript @@hello 1,2,3,4 @@ -330,28 +330,28 @@ The calling semantics of @@ are similar to @. Calling a @@ name will pass the cl -## Class Declaration Statements +## Klassendeklarations-Statements -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. +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. -Here is an alternative way to create a class variable compared to what's described above: +Hier ist eine alternative Möglichkeit, eine Klassenvariable zu erstellen: ```yuescript class Things - @class_var = "hello world" + @class_var = "Hallo Welt" ``` ```yue class Things - @class_var = "hello world" + @class_var = "Hallo Welt" ``` -These expressions are executed after all the properties have been added to the base. +Diese Ausdrücke werden ausgeführt, nachdem alle Eigenschaften zur Basis hinzugefügt wurden. -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: +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: ```yuescript class MoreThings @@ -359,7 +359,7 @@ class MoreThings log = (msg) -> print "LOG:", msg some_method: => - log "hello world: " .. secret + log "Hallo Welt: " .. secret ``` @@ -369,16 +369,16 @@ class MoreThings log = (msg) -> print "LOG:", msg some_method: => - log "hello world: " .. secret + log "Hallo Welt: " .. secret ``` -## @ and @@ Values +## @- und @@-Werte -When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.__class. +Wenn `@` und `@@` vor einem Namen stehen, repräsentieren sie den Namen in `self` bzw. `self.__class`. -If they are used all by themselves, they are aliases for self and self.__class. +Wenn sie alleine verwendet werden, sind sie Aliase für `self` und `self.__class`. ```yuescript assert @ == self @@ -393,7 +393,7 @@ assert @@ == self.__class -For example, a quick way to create a new instance of the same class from an instance method using @@: +Zum Beispiel kannst du mit `@@` in einer Instanzmethode schnell eine neue Instanz derselben Klasse erzeugen: ```yuescript some_instance_method = (...) => @@ ... @@ -406,15 +406,15 @@ some_instance_method = (...) => @@ ... -## Constructor Property Promotion +## Konstruktor-Property-Promotion -To reduce the boilerplate code for definition of simple value objects. You can write a simple class like: +Um Boilerplate beim Definieren einfacher Value-Objekte zu reduzieren, kannst du eine Klasse so schreiben: ```yuescript class Something new: (@foo, @bar, @@biz, @@baz) => --- Which is short for +-- Kurzform für class Something new: (foo, bar, biz, baz) => @@ -429,7 +429,7 @@ class Something class Something new: (@foo, @bar, @@biz, @@baz) => --- Which is short for +-- Kurzform für class Something new: (foo, bar, biz, baz) => @@ -441,7 +441,7 @@ class Something -You can also use this syntax for a common function to initialize a object's fields. +Du kannst diese Syntax auch für eine gemeinsame Funktion verwenden, um Objektfelder zu initialisieren. ```yuescript new = (@fieldA, @fieldB) => @ @@ -458,9 +458,9 @@ print obj -## Class Expressions +## Klassenausdrücke -The class syntax can also be used as an expression which can be assigned to a variable or explicitly returned. +Die `class`-Syntax kann auch als Ausdruck verwendet werden, der einer Variable zugewiesen oder explizit zurückgegeben wird. ```yuescript x = class Bucket @@ -477,9 +477,9 @@ x = class Bucket -## Anonymous classes +## Anonyme Klassen -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. +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. ```yuescript BigBucket = class extends Bucket @@ -498,7 +498,7 @@ assert Bucket.__name == "BigBucket" -You can even leave off the body, meaning you can write a blank anonymous class like this: +Du kannst sogar den Körper weglassen und eine leere anonyme Klasse schreiben: ```yuescript x = class @@ -513,7 +513,7 @@ x = class ## Class Mixing -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. +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. ```yuescript MyIndex = __index: var: 1 @@ -530,7 +530,7 @@ class Y using X y = Y! y\func! -assert y.__class.__parent ~= X -- X is not parent of Y +assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y ``` @@ -549,7 +549,7 @@ class Y using X y = Y! y\func! -assert y.__class.__parent ~= X -- X is not parent of Y +assert y.__class.__parent ~= X -- X ist nicht die Elternklasse von Y ``` 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 @@ -# With Statement +# With-Statement +Ein häufiges Muster bei der Erstellung eines Objekts ist, unmittelbar danach eine Reihe von Funktionen aufzurufen und Eigenschaften zu setzen. -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. +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. -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. +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. -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. - -For example, we work with a newly created object: +Zum Beispiel arbeiten wir mit einem neu erstellten Objekt: ```yuescript with Person! @@ -28,22 +27,22 @@ with Person! -The with statement can also be used as an expression which returns the value it has been giving access to. +Das `with`-Statement kann auch als Ausdruck verwendet werden und gibt den Wert zurück, auf den es Zugriff gewährt. ```yuescript -file = with File "favorite_foods.txt" +file = with File "Lieblingsessen.txt" \set_encoding "utf8" ``` ```yue -file = with File "favorite_foods.txt" +file = with File "Lieblingsessen.txt" \set_encoding "utf8" ``` -Or… +Oder … ```yuescript create_person = (name, relatives) -> @@ -66,26 +65,26 @@ me = create_person "Leaf", [dad, mother, sister] -In this usage, with can be seen as a special form of the K combinator. +In dieser Verwendung kann `with` als spezielle Form des K-Kombinators gesehen werden. -The expression in the with statement can also be an assignment, if you want to give a name to the expression. +Der Ausdruck im `with`-Statement kann auch eine Zuweisung sein, wenn du dem Ausdruck einen Namen geben willst. ```yuescript -with str := "Hello" - print "original:", str - print "upper:", \upper! +with str := "Hallo" + print "Original:", str + print "Großbuchstaben:", \upper! ``` ```yue -with str := "Hello" - print "original:", str - print "upper:", \upper! +with str := "Hallo" + print "Original:", str + print "Großbuchstaben:", \upper! ``` -You can access special keys with `[]` in a `with` statement. +Du kannst in einem `with`-Statement über `[]` auf spezielle Schlüssel zugreifen. ```yuescript with tb @@ -94,7 +93,7 @@ with tb with [abc] [3] = [2]\func! ["key-name"] = value - [] = "abc" -- appending to "tb" + [] = "abc" -- an "tb" anhängen ``` @@ -105,12 +104,12 @@ with tb with [abc] [3] = [2]\func! ["key-name"] = value - [] = "abc" -- appending to "tb" + [] = "abc" -- an "tb" anhängen ``` -`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. +`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. ```yuescript 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 @@ -# License: MIT +# Lizenz: MIT -Copyright (c) 2017-2026 Li Jin \ +Hinweis: Die MIT-Lizenz ist unten im englischen Originaltext wiedergegeben. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Urheberrecht (c) 2017-2026 Li Jin -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +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: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Der obige Urheberrechtshinweis und dieser Genehmigungshinweis müssen in allen Kopien oder wesentlichen Teilen der Software enthalten sein. - +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 @@ -# The YueScript Library +# Die YueScript-Bibliothek -Access it by `local yue = require("yue")` in Lua. +Zugriff in Lua über `local yue = require("yue")`. ## yue -**Description:** +**Beschreibung:** -The YueScript language library. +Die YueScript-Sprachbibliothek. ### version -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The YueScript version. +Die YueScript-Version. -**Signature:** +**Signatur:** ```lua version: string ``` ### dirsep -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The file separator for the current platform. +Der Dateitrennzeichen-String der aktuellen Plattform. -**Signature:** +**Signatur:** ```lua dirsep: string ``` ### yue_compiled -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The compiled module code cache. +Der Cache für kompilierten Modulcode. -**Signature:** +**Signatur:** ```lua yue_compiled: {string: string} ``` ### to_lua -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -The YueScript compiling function. It compiles the YueScript code to Lua code. +Die YueScript-Compilerfunktion. Sie kompiliert YueScript-Code zu Lua-Code. -**Signature:** +**Signatur:** ```lua to_lua: function(code: string, config?: Config): --[[codes]] string | nil, @@ -63,682 +63,682 @@ to_lua: function(code: string, config?: Config): --[[globals]] {{string, integer, integer}} | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| code | string | The YueScript code. | -| config | Config | [Optional] The compiler options. | +| code | string | Der YueScript-Code. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| string \| nil | The compiled Lua code, or nil if the compilation failed. | -| string \| nil | The error message, or nil if the compilation succeeded. | -| {{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. | +| string \| nil | Der kompilierte Lua-Code oder `nil`, falls die Kompilierung fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls die Kompilierung erfolgreich war. | +| {{string, integer, integer}} \| nil | Die globalen Variablen im Code (mit Name, Zeile und Spalte) oder `nil`, wenn die Compiler-Option `lint_global` false ist. | ### file_exist -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -The source file existence checking function. Can be overridden to customize the behavior. +Prüft, ob eine Quelldatei existiert. Kann überschrieben werden, um das Verhalten anzupassen. -**Signature:** +**Signatur:** ```lua file_exist: function(filename: string): boolean ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | +| filename | string | Der Dateiname. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| boolean | Whether the file exists. | +| boolean | Ob die Datei existiert. | ### read_file -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -The source file reading function. Can be overridden to customize the behavior. +Liest eine Quelldatei. Kann überschrieben werden, um das Verhalten anzupassen. -**Signature:** +**Signatur:** ```lua read_file: function(filename: string): string ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | +| filename | string | Der Dateiname. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| string | The file content. | +| string | Der Dateiinhalt. | ### insert_loader -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Insert the YueScript loader to the package loaders (searchers). +Fügt den YueScript-Loader in die Package-Loader (Searcher) ein. -**Signature:** +**Signatur:** ```lua insert_loader: function(pos?: integer): boolean ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| pos | integer | [Optional] The position to insert the loader. Default is 3. | +| pos | integer | [Optional] Position, an der der Loader eingefügt wird. Standard ist 3. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | +| boolean | Ob der Loader erfolgreich eingefügt wurde. Scheitert, wenn er bereits eingefügt ist. | ### remove_loader -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Remove the YueScript loader from the package loaders (searchers). +Entfernt den YueScript-Loader aus den Package-Loadern (Searchern). -**Signature:** +**Signatur:** ```lua remove_loader: function(): boolean ``` -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | +| boolean | Ob der Loader erfolgreich entfernt wurde. Scheitert, wenn er nicht eingefügt ist. | ### loadstring -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a string into a function. +Lädt YueScript-Code aus einem String in eine Funktion. -**Signature:** +**Signatur:** ```lua loadstring: function(input: string, chunkname: string, env: table, config?: Config): --[[loaded function]] nil | function(...: any): (any...), --[[error]] string | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| input | string | The YueScript code. | -| chunkname | string | The name of the code chunk. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | +| input | string | Der YueScript-Code. | +| chunkname | string | Der Name des Code-Chunks. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | ### loadstring -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a string into a function. +Lädt YueScript-Code aus einem String in eine Funktion. -**Signature:** +**Signatur:** ```lua loadstring: function(input: string, chunkname: string, config?: Config): --[[loaded function]] nil | function(...: any): (any...), --[[error]] string | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| input | string | The YueScript code. | -| chunkname | string | The name of the code chunk. | -| config | Config | [Optional] The compiler options. | +| input | string | Der YueScript-Code. | +| chunkname | string | Der Name des Code-Chunks. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | ### loadstring -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a string into a function. +Lädt YueScript-Code aus einem String in eine Funktion. -**Signature:** +**Signatur:** ```lua loadstring: function(input: string, config?: Config): --[[loaded function]] nil | function(...: any): (any...), --[[error]] string | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| input | string | The YueScript code. | -| config | Config | [Optional] The compiler options. | +| input | string | Der YueScript-Code. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | ### loadfile -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a file into a function. +Lädt YueScript-Code aus einer Datei in eine Funktion. -**Signature:** +**Signatur:** ```lua loadfile: function(filename: string, env: table, config?: Config): nil | function(...: any): (any...), string | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | +| filename | string | Der Dateiname. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | ### loadfile -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a file into a function. +Lädt YueScript-Code aus einer Datei in eine Funktion. -**Signature:** +**Signatur:** ```lua loadfile: function(filename: string, config?: Config): nil | function(...: any): (any...), string | nil ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | -| config | Config | [Optional] The compiler options. | +| filename | string | Der Dateiname. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| function \| nil | The loaded function, or nil if the loading failed. | -| string \| nil | The error message, or nil if the loading succeeded. | +| function \| nil | Die geladene Funktion oder `nil`, falls das Laden fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls das Laden erfolgreich war. | ### dofile -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a file into a function and executes it. +Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. -**Signature:** +**Signatur:** ```lua dofile: function(filename: string, env: table, config?: Config): any... ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | -| env | table | The environment table. | -| config | Config | [Optional] The compiler options. | +| filename | string | Der Dateiname. | +| env | table | Die Environment-Tabelle. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| any... | The return values of the loaded function. | +| any... | Die Rückgabewerte der geladenen Funktion. | ### dofile -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads YueScript code from a file into a function and executes it. +Lädt YueScript-Code aus einer Datei in eine Funktion und führt sie aus. -**Signature:** +**Signatur:** ```lua dofile: function(filename: string, config?: Config): any... ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| filename | string | The file name. | -| config | Config | [Optional] The compiler options. | +| filename | string | Der Dateiname. | +| config | Config | [Optional] Die Compiler-Optionen. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| any... | The return values of the loaded function. | +| any... | Die Rückgabewerte der geladenen Funktion. | ### find_modulepath -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Resolves the YueScript module name to the file path. +Löst den YueScript-Modulnamen in einen Dateipfad auf. -**Signature:** +**Signatur:** ```lua find_modulepath: function(name: string): string ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| name | string | The module name. | +| name | string | Der Modulname. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| string | The file path. | +| string | Der Dateipfad. | ### pcall -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Calls a function in protected mode. -Catches any errors and returns a status code and results or error object. -Rewrites the error line number to the original line number in the YueScript code when errors occur. +Ruft eine Funktion im geschützten Modus auf. +Fängt Fehler ab und gibt einen Statuscode sowie Ergebnisse oder ein Fehlerobjekt zurück. +Schreibt die Fehlerzeilennummer bei Fehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. -**Signature:** +**Signatur:** ```lua pcall: function(f: function, ...: any): boolean, any... ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| f | function | The function to call. | -| ... | any | Arguments to pass to the function. | +| f | function | Die aufzurufende Funktion. | +| ... | any | Argumente für die Funktion. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| boolean, ... | Status code and function results or error object. | +| boolean, ... | Statuscode und Funktionsresultate oder Fehlerobjekt. | ### require -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Loads a given module. Can be either a Lua module or a YueScript module. -Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. +Lädt ein Modul (Lua oder YueScript). +Schreibt die Fehlerzeilennummer auf die ursprüngliche Zeilennummer im YueScript-Code um, wenn das Modul ein YueScript-Modul ist und das Laden fehlschlägt. -**Signature:** +**Signatur:** ```lua require: function(name: string): any... ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| modname | string | The name of the module to load. | +| modname | string | Der Name des zu ladenden Moduls. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| 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. | +| 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. | ### p -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Inspects the structures of the passed values and prints string representations. +Inspiziert die Struktur der übergebenen Werte und gibt String-Repräsentationen aus. -**Signature:** +**Signatur:** ```lua p: function(...: any) ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| ... | any | The values to inspect. | +| ... | any | Die zu inspizierenden Werte. | ### options -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The current compiler options. +Die aktuellen Compiler-Optionen. -**Signature:** +**Signatur:** ```lua options: Config.Options ``` ### traceback -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. +Die Traceback-Funktion, die Stacktrace-Zeilennummern auf die ursprünglichen Zeilennummern im YueScript-Code umschreibt. -**Signature:** +**Signatur:** ```lua traceback: function(message: string): string ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| message | string | The traceback message. | +| message | string | Die Traceback-Nachricht. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| string | The rewritten traceback message. | +| string | Die umgeschriebene Traceback-Nachricht. | ### is_ast -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Checks whether the code matches the specified AST. +Prüft, ob der Code dem angegebenen AST entspricht. -**Signature:** +**Signatur:** ```lua is_ast: function(astName: string, code: string): boolean ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| astName | string | The AST name. | -| code | string | The code. | +| astName | string | Der AST-Name. | +| code | string | Der Code. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| boolean | Whether the code matches the AST. | +| boolean | Ob der Code dem AST entspricht. | ### AST -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The AST type definition with name, row, column and sub nodes. +Die AST-Typdefinition mit Name, Zeile, Spalte und Unterknoten. -**Signature:** +**Signatur:** ```lua type AST = {string, integer, integer, any} ``` ### to_ast -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Converts the code to the AST. +Konvertiert Code in AST. -**Signature:** +**Signatur:** ```lua to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): --[[AST]] AST | nil, --[[error]] nil | string ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| code | string | The code. | -| flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | -| astName | string | [Optional] The AST name. Default is "File". | -| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | +| code | string | Der Code. | +| flattenLevel | integer | [Optional] Der Flatten-Level. Höher bedeutet mehr Flattening. Standard ist 0. Maximum ist 2. | +| astName | string | [Optional] Der AST-Name. Standard ist "File". | +| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist false. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| AST \| nil | The AST, or nil if the conversion failed. | -| string \| nil | The error message, or nil if the conversion succeeded. | +| AST \| nil | Der AST oder `nil`, falls die Konvertierung fehlgeschlagen ist. | +| string \| nil | Die Fehlermeldung oder `nil`, falls die Konvertierung erfolgreich war. | ### format -**Type:** Function. +**Typ:** Funktion. -**Description:** +**Beschreibung:** -Formats the YueScript code. +Formatiert den YueScript-Code. -**Signature:** +**Signatur:** ```lua format: function(code: string, tabSize?: number, reserveComment?: boolean): string ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| code | string | The code. | -| tabSize | integer | [Optional] The tab size. Default is 4. | -| reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | +| code | string | Der Code. | +| tabSize | integer | [Optional] Die Tab-Größe. Standard ist 4. | +| reserveComment | boolean | [Optional] Ob die ursprünglichen Kommentare beibehalten werden. Standard ist true. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| string | The formatted code. | +| string | Der formatierte Code. | ### __call -**Type:** Metamethod. +**Typ:** Metamethod. -**Description:** +**Beschreibung:** -Requires the YueScript module. -Rewrites the error line number to the original line number in the YueScript code when loading fails. +Required das YueScript-Modul. +Schreibt die Fehlerzeilennummer bei Ladefehlern auf die ursprüngliche Zeilennummer im YueScript-Code um. -**Signature:** +**Signatur:** ```lua metamethod __call: function(self: yue, module: string): any... ``` -**Parameters:** +**Parameter:** -| Parameter | Type | Description | +| Parameter | Typ | Beschreibung | | --- | --- | --- | -| module | string | The module name. | +| module | string | Der Modulname. | -**Returns:** +**Rückgabe:** -| Return Type | Description | +| Rückgabetyp | Beschreibung | | --- | --- | -| any | The module value. | +| any | Der Modulwert. | ## Config -**Description:** +**Beschreibung:** -The compiler compile options. +Die Compiler-Optionen. ### lint_global -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should collect the global variables appearing in the code. +Ob der Compiler die globalen Variablen im Code sammeln soll. -**Signature:** +**Signatur:** ```lua lint_global: boolean ``` ### implicit_return_root -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should do an implicit return for the root code block. +Ob der Compiler für den Root-Codeblock ein implizites Return verwenden soll. -**Signature:** +**Signatur:** ```lua implicit_return_root: boolean ``` ### reserve_line_number -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should reserve the original line number in the compiled code. +Ob der Compiler die ursprüngliche Zeilennummer im kompilierten Code beibehalten soll. -**Signature:** +**Signatur:** ```lua reserve_line_number: boolean ``` ### reserve_comment -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should reserve the original comments in the compiled code. +Ob der Compiler die ursprünglichen Kommentare im kompilierten Code beibehalten soll. -**Signature:** +**Signatur:** ```lua reserve_comment: boolean ``` ### space_over_tab -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should use the space character instead of the tab character in the compiled code. +Ob der Compiler statt Tabzeichen Leerzeichen verwenden soll. -**Signature:** +**Signatur:** ```lua space_over_tab: boolean ``` ### same_module -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. +Ob der Compiler den zu kompilierenden Code als dasselbe aktuell kompilierte Modul behandeln soll. Nur für internen Gebrauch. -**Signature:** +**Signatur:** ```lua same_module: boolean ``` ### line_offset -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether the compiler error message should include the line number offset. For internal use only. +Ob die Compiler-Fehlermeldung einen Zeilennummern-Offset enthalten soll. Nur für internen Gebrauch. -**Signature:** +**Signatur:** ```lua line_offset: integer ``` ### yue.Config.LuaTarget -**Type:** Enumeration. +**Typ:** Enumeration. -**Description:** +**Beschreibung:** -The target Lua version enumeration. +Die Ziel-Lua-Version. -**Signature:** +**Signatur:** ```lua enum LuaTarget "5.1" @@ -751,71 +751,71 @@ end ### options -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The extra options to be passed to the compilation function. +Zusätzliche Optionen für die Kompilierung. -**Signature:** +**Signatur:** ```lua options: Options ``` ## Options -**Description:** +**Beschreibung:** -The extra compiler options definition. +Zusätzliche Compiler-Optionen. ### target -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The target Lua version for the compilation. +Die Ziel-Lua-Version für die Kompilierung. -**Signature:** +**Signatur:** ```lua target: LuaTarget ``` ### path -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -The extra module search path. +Zusätzlicher Modul-Suchpfad. -**Signature:** +**Signatur:** ```lua path: string ``` ### dump_locals -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether to dump the local variables in the traceback error message. Default is false. +Ob lokale Variablen in Traceback-Fehlermeldungen ausgegeben werden sollen. Standard ist false. -**Signature:** +**Signatur:** ```lua dump_locals: boolean ``` ### simplified -**Type:** Field. +**Typ:** Feld. -**Description:** +**Beschreibung:** -Whether to simplify the error message. Default is true. +Ob Fehlermeldungen vereinfacht werden sollen. Standard ist true. -**Signature:** +**Signatur:** ```lua simplified: boolean ``` -- cgit v1.2.3-55-g6feb