diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-06 11:54:32 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-06 11:54:32 +0800 |
| commit | 1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d (patch) | |
| tree | 1d5c39eadcbe086d2a592ac76c8f1d288adfbe9d /doc/docs/id-id | |
| parent | aa3ecc7badfb39cb9167fb95c9a678257c1d9954 (diff) | |
| download | yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.tar.gz yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.tar.bz2 yuescript-1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d.zip | |
Updated docs.v0.32.9
Diffstat (limited to 'doc/docs/id-id')
35 files changed, 883 insertions, 897 deletions
diff --git a/doc/docs/id-id/doc/advanced/do.md b/doc/docs/id-id/doc/advanced/do.md index 4990d6f..ebbd2e2 100644 --- a/doc/docs/id-id/doc/advanced/do.md +++ b/doc/docs/id-id/doc/advanced/do.md | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | # Do | 1 | # Do |
| 2 | 2 | ||
| 3 | When used as a statement, do works just like it does in Lua. | 3 | Saat digunakan sebagai pernyataan, `do` bekerja seperti di Lua. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | do | 6 | do |
| 7 | var = "hello" | 7 | var = "hello" |
| 8 | print var | 8 | print var |
| 9 | print var -- nil here | 9 | print var -- nil di sini |
| 10 | ``` | 10 | ``` |
| 11 | <YueDisplay> | 11 | <YueDisplay> |
| 12 | 12 | ||
| @@ -14,12 +14,12 @@ print var -- nil here | |||
| 14 | do | 14 | do |
| 15 | var = "hello" | 15 | var = "hello" |
| 16 | print var | 16 | print var |
| 17 | print var -- nil here | 17 | print var -- nil di sini |
| 18 | ``` | 18 | ``` |
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. | 22 | `do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | counter = do | 25 | counter = do |
diff --git a/doc/docs/id-id/doc/advanced/line-decorators.md b/doc/docs/id-id/doc/advanced/line-decorators.md index 292bc77..e90e205 100644 --- a/doc/docs/id-id/doc/advanced/line-decorators.md +++ b/doc/docs/id-id/doc/advanced/line-decorators.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Line Decorators | 1 | # Dekorator Baris |
| 2 | 2 | ||
| 3 | For convenience, the for loop and if statement can be applied to single statements at the end of the line: | 3 | Untuk kemudahan, loop for dan pernyataan if dapat diterapkan pada pernyataan tunggal di akhir baris: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | print "hello world" if name == "Rob" | 6 | print "hello world" if name == "Rob" |
| @@ -13,7 +13,7 @@ print "hello world" if name == "Rob" | |||
| 13 | 13 | ||
| 14 | </YueDisplay> | 14 | </YueDisplay> |
| 15 | 15 | ||
| 16 | And with basic loops: | 16 | Dan dengan loop dasar: |
| 17 | 17 | ||
| 18 | ```yuescript | 18 | ```yuescript |
| 19 | print "item: ", item for item in *items | 19 | print "item: ", item for item in *items |
| @@ -26,7 +26,7 @@ print "item: ", item for item in *items | |||
| 26 | 26 | ||
| 27 | </YueDisplay> | 27 | </YueDisplay> |
| 28 | 28 | ||
| 29 | And with while loops: | 29 | Dan dengan loop while: |
| 30 | 30 | ||
| 31 | ```yuescript | 31 | ```yuescript |
| 32 | game\update! while game\isRunning! | 32 | game\update! while game\isRunning! |
diff --git a/doc/docs/id-id/doc/advanced/macro.md b/doc/docs/id-id/doc/advanced/macro.md index 6d194c3..ce0bafa 100644 --- a/doc/docs/id-id/doc/advanced/macro.md +++ b/doc/docs/id-id/doc/advanced/macro.md | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | # Macro | 1 | # Makro |
| 2 | 2 | ||
| 3 | ## Common Usage | 3 | ## Penggunaan Umum |
| 4 | 4 | ||
| 5 | Macro function is used for evaluating a string in the compile time and insert the generated codes into final compilation. | 5 | Fungsi macro digunakan untuk mengevaluasi string pada waktu kompilasi dan menyisipkan kode yang dihasilkan ke kompilasi akhir. |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | macro PI2 = -> math.pi * 2 | 8 | macro PI2 = -> math.pi * 2 |
| @@ -27,7 +27,7 @@ $asserts item ~= nil | |||
| 27 | $config false | 27 | $config false |
| 28 | value = $assert item | 28 | value = $assert item |
| 29 | 29 | ||
| 30 | -- the passed expressions are treated as strings | 30 | -- ekspresi yang dikirim diperlakukan sebagai string |
| 31 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" | 31 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" |
| 32 | if $and f1!, f2!, f3! | 32 | if $and f1!, f2!, f3! |
| 33 | print "OK" | 33 | print "OK" |
| @@ -57,7 +57,7 @@ $asserts item ~= nil | |||
| 57 | $config false | 57 | $config false |
| 58 | value = $assert item | 58 | value = $assert item |
| 59 | 59 | ||
| 60 | -- the passed expressions are treated as strings | 60 | -- ekspresi yang dikirim diperlakukan sebagai string |
| 61 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" | 61 | macro and = (...) -> "#{ table.concat {...}, ' and ' }" |
| 62 | if $and f1!, f2!, f3! | 62 | if $and f1!, f2!, f3! |
| 63 | print "OK" | 63 | print "OK" |
| @@ -65,29 +65,29 @@ if $and f1!, f2!, f3! | |||
| 65 | 65 | ||
| 66 | </YueDisplay> | 66 | </YueDisplay> |
| 67 | 67 | ||
| 68 | ## Insert Raw Codes | 68 | ## Menyisipkan Kode Mentah |
| 69 | 69 | ||
| 70 | A macro function can either return a YueScript string or a config table containing Lua codes. | 70 | Fungsi macro bisa mengembalikan string YueScript atau tabel konfigurasi yang berisi kode Lua. |
| 71 | ```yuescript | 71 | ```yuescript |
| 72 | macro yueFunc = (var) -> "local #{var} = ->" | 72 | macro yueFunc = (var) -> "local #{var} = ->" |
| 73 | $yueFunc funcA | 73 | $yueFunc funcA |
| 74 | funcA = -> "fail to assign to the Yue macro defined variable" | 74 | funcA = -> "gagal meng-assign ke variabel yang didefinisikan oleh macro Yue" |
| 75 | 75 | ||
| 76 | macro luaFunc = (var) -> { | 76 | macro luaFunc = (var) -> { |
| 77 | code: "local function #{var}() end" | 77 | code: "local function #{var}() end" |
| 78 | type: "lua" | 78 | type: "lua" |
| 79 | } | 79 | } |
| 80 | $luaFunc funcB | 80 | $luaFunc funcB |
| 81 | funcB = -> "fail to assign to the Lua macro defined variable" | 81 | funcB = -> "gagal meng-assign ke variabel yang didefinisikan oleh macro Lua" |
| 82 | 82 | ||
| 83 | macro lua = (code) -> { | 83 | macro lua = (code) -> { |
| 84 | :code | 84 | :code |
| 85 | type: "lua" | 85 | type: "lua" |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | -- the raw string leading and ending symbols are auto trimed | 88 | -- simbol awal dan akhir string mentah otomatis di-trim |
| 89 | $lua[==[ | 89 | $lua[==[ |
| 90 | -- raw Lua codes insertion | 90 | -- penyisipan kode Lua mentah |
| 91 | if cond then | 91 | if cond then |
| 92 | print("output") | 92 | print("output") |
| 93 | end | 93 | end |
| @@ -98,23 +98,23 @@ end | |||
| 98 | ```yue | 98 | ```yue |
| 99 | macro yueFunc = (var) -> "local #{var} = ->" | 99 | macro yueFunc = (var) -> "local #{var} = ->" |
| 100 | $yueFunc funcA | 100 | $yueFunc funcA |
| 101 | funcA = -> "fail to assign to the Yue macro defined variable" | 101 | funcA = -> "gagal meng-assign ke variabel yang didefinisikan oleh macro Yue" |
| 102 | 102 | ||
| 103 | macro luaFunc = (var) -> { | 103 | macro luaFunc = (var) -> { |
| 104 | code: "local function #{var}() end" | 104 | code: "local function #{var}() end" |
| 105 | type: "lua" | 105 | type: "lua" |
| 106 | } | 106 | } |
| 107 | $luaFunc funcB | 107 | $luaFunc funcB |
| 108 | funcB = -> "fail to assign to the Lua macro defined variable" | 108 | funcB = -> "gagal meng-assign ke variabel yang didefinisikan oleh macro Lua" |
| 109 | 109 | ||
| 110 | macro lua = (code) -> { | 110 | macro lua = (code) -> { |
| 111 | :code | 111 | :code |
| 112 | type: "lua" | 112 | type: "lua" |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | -- the raw string leading and ending symbols are auto trimed | 115 | -- simbol awal dan akhir string mentah otomatis di-trim |
| 116 | $lua[==[ | 116 | $lua[==[ |
| 117 | -- raw Lua codes insertion | 117 | -- penyisipan kode Lua mentah |
| 118 | if cond then | 118 | if cond then |
| 119 | print("output") | 119 | print("output") |
| 120 | end | 120 | end |
| @@ -125,7 +125,7 @@ end | |||
| 125 | 125 | ||
| 126 | ## Export Macro | 126 | ## Export Macro |
| 127 | 127 | ||
| 128 | Macro functions can be exported from a module and get imported in another module. You have to put export macro functions in a single file to be used, and only macro definition, macro importing and macro expansion in place can be put into the macro exporting module. | 128 | Fungsi macro dapat diekspor dari modul dan diimpor di modul lain. Anda harus menaruh fungsi macro export dalam satu file agar dapat digunakan, dan hanya definisi macro, impor macro, dan ekspansi macro yang boleh ada di modul export macro. |
| 129 | ```yuescript | 129 | ```yuescript |
| 130 | -- file: utils.yue | 130 | -- file: utils.yue |
| 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | 131 | export macro map = (items, action) -> "[#{action} for _ in *#{items}]" |
| @@ -135,8 +135,8 @@ export macro foreach = (items, action) -> "for _ in *#{items} | |||
| 135 | 135 | ||
| 136 | -- file main.yue | 136 | -- file main.yue |
| 137 | import "utils" as { | 137 | import "utils" as { |
| 138 | $, -- symbol to import all macros | 138 | $, -- simbol untuk mengimpor semua macro |
| 139 | $foreach: $each -- rename macro $foreach to $each | 139 | $foreach: $each -- ganti nama macro $foreach menjadi $each |
| 140 | } | 140 | } |
| 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 141 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 142 | ``` | 142 | ``` |
| @@ -150,11 +150,11 @@ export macro foreach = (items, action) -> "for _ in *#{items} | |||
| 150 | #{action}" | 150 | #{action}" |
| 151 | 151 | ||
| 152 | -- file main.yue | 152 | -- file main.yue |
| 153 | -- import function is not available in browser, try it in a real environment | 153 | -- fungsi import tidak tersedia di browser, coba di lingkungan nyata |
| 154 | --[[ | 154 | --[[ |
| 155 | import "utils" as { | 155 | import "utils" as { |
| 156 | $, -- symbol to import all macros | 156 | $, -- simbol untuk mengimpor semua macro |
| 157 | $foreach: $each -- rename macro $foreach to $each | 157 | $foreach: $each -- ganti nama macro $foreach menjadi $each |
| 158 | } | 158 | } |
| 159 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ | 159 | [1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ |
| 160 | ]] | 160 | ]] |
| @@ -162,25 +162,25 @@ import "utils" as { | |||
| 162 | 162 | ||
| 163 | </YueDisplay> | 163 | </YueDisplay> |
| 164 | 164 | ||
| 165 | ## Builtin Macro | 165 | ## Macro Bawaan |
| 166 | 166 | ||
| 167 | There are some builtin macros but you can override them by declaring macros with the same names. | 167 | Ada beberapa macro bawaan tetapi Anda bisa menimpanya dengan mendeklarasikan macro dengan nama yang sama. |
| 168 | ```yuescript | 168 | ```yuescript |
| 169 | print $FILE -- get string of current module name | 169 | print $FILE -- mendapatkan string nama modul saat ini |
| 170 | print $LINE -- get number 2 | 170 | print $LINE -- mendapatkan angka 2 |
| 171 | ``` | 171 | ``` |
| 172 | <YueDisplay> | 172 | <YueDisplay> |
| 173 | 173 | ||
| 174 | ```yue | 174 | ```yue |
| 175 | print $FILE -- get string of current module name | 175 | print $FILE -- mendapatkan string nama modul saat ini |
| 176 | print $LINE -- get number 2 | 176 | print $LINE -- mendapatkan angka 2 |
| 177 | ``` | 177 | ``` |
| 178 | 178 | ||
| 179 | </YueDisplay> | 179 | </YueDisplay> |
| 180 | 180 | ||
| 181 | ## Generating Macros with Macros | 181 | ## Menghasilkan Macro dengan Macro |
| 182 | 182 | ||
| 183 | In YueScript, macro functions allow you to generate code at compile time. By nesting macro functions, you can create more complex generation patterns. This feature enables you to define a macro function that generates another macro function, allowing for more dynamic code generation. | 183 | Di YueScript, fungsi macro memungkinkan Anda menghasilkan kode pada waktu kompilasi. Dengan menumpuk fungsi macro, Anda dapat membuat pola generasi yang lebih kompleks. Fitur ini memungkinkan Anda mendefinisikan fungsi macro yang menghasilkan fungsi macro lain, sehingga menghasilkan kode yang lebih dinamis. |
| 184 | 184 | ||
| 185 | ```yuescript | 185 | ```yuescript |
| 186 | macro Enum = (...) -> | 186 | macro Enum = (...) -> |
| @@ -222,9 +222,9 @@ print "Valid enum type:", $BodyType Static | |||
| 222 | 222 | ||
| 223 | </YueDisplay> | 223 | </YueDisplay> |
| 224 | 224 | ||
| 225 | ## Argument Validation | 225 | ## Validasi Argumen |
| 226 | 226 | ||
| 227 | You can declare the expected AST node types in the argument list, and check whether the incoming macro arguments meet the expectations at compile time. | 227 | Anda dapat mendeklarasikan tipe node AST yang diharapkan dalam daftar argumen, dan memeriksa apakah argumen macro yang masuk memenuhi harapan pada waktu kompilasi. |
| 228 | 228 | ||
| 229 | ```yuescript | 229 | ```yuescript |
| 230 | macro printNumAndStr = (num `Num, str `String) -> | | 230 | macro printNumAndStr = (num `Num, str `String) -> | |
| @@ -249,7 +249,7 @@ $printNumAndStr 123, "hello" | |||
| 249 | 249 | ||
| 250 | </YueDisplay> | 250 | </YueDisplay> |
| 251 | 251 | ||
| 252 | If you need more flexible argument checking, you can use the built-in `$is_ast` macro function to manually check at the appropriate place. | 252 | Jika Anda membutuhkan pengecekan argumen yang lebih fleksibel, Anda dapat menggunakan fungsi macro bawaan `$is_ast` untuk memeriksa secara manual pada tempat yang tepat. |
| 253 | 253 | ||
| 254 | ```yuescript | 254 | ```yuescript |
| 255 | macro printNumAndStr = (num, str) -> | 255 | macro printNumAndStr = (num, str) -> |
| @@ -272,4 +272,4 @@ $printNumAndStr 123, "hello" | |||
| 272 | 272 | ||
| 273 | </YueDisplay> | 273 | </YueDisplay> |
| 274 | 274 | ||
| 275 | For more details about available AST nodes, please refer to the uppercased definitions in [yue_parser.cpp](https://github.com/IppClub/YueScript/blob/main/src/yuescript/yue_parser.cpp). | 275 | Untuk detail lebih lanjut tentang node AST yang tersedia, silakan lihat definisi huruf besar di [yue_parser.cpp](https://github.com/IppClub/YueScript/blob/main/src/yuescript/yue_parser.cpp). |
diff --git a/doc/docs/id-id/doc/advanced/module.md b/doc/docs/id-id/doc/advanced/module.md index c955092..dd97a32 100644 --- a/doc/docs/id-id/doc/advanced/module.md +++ b/doc/docs/id-id/doc/advanced/module.md | |||
| @@ -1,28 +1,28 @@ | |||
| 1 | # Module | 1 | # Modul |
| 2 | 2 | ||
| 3 | ## Import | 3 | ## Import |
| 4 | 4 | ||
| 5 | The import statement is a syntax sugar for requiring a module or help extracting items from an imported module. The imported items are const by default. | 5 | Pernyataan `import` adalah sintaks sugar untuk me-require modul atau membantu mengekstrak item dari modul yang diimpor. Item yang diimpor bersifat `const` secara default. |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | -- used as table destructuring | 8 | -- digunakan sebagai destrukturisasi tabel |
| 9 | do | 9 | do |
| 10 | import insert, concat from table | 10 | import insert, concat from table |
| 11 | -- report error when assigning to insert, concat | 11 | -- akan error saat meng-assign ke insert, concat |
| 12 | import C, Ct, Cmt from require "lpeg" | 12 | import C, Ct, Cmt from require "lpeg" |
| 13 | -- shortcut for implicit requiring | 13 | -- shortcut untuk require implisit |
| 14 | import x, y, z from 'mymodule' | 14 | import x, y, z from 'mymodule' |
| 15 | -- import with Python style | 15 | -- import gaya Python |
| 16 | from 'module' import a, b, c | 16 | from 'module' import a, b, c |
| 17 | 17 | ||
| 18 | -- shortcut for requring a module | 18 | -- shortcut untuk require modul |
| 19 | do | 19 | do |
| 20 | import 'module' | 20 | import 'module' |
| 21 | import 'module_x' | 21 | import 'module_x' |
| 22 | import "d-a-s-h-e-s" | 22 | import "d-a-s-h-e-s" |
| 23 | import "module.part" | 23 | import "module.part" |
| 24 | 24 | ||
| 25 | -- requring module with aliasing or table destructuring | 25 | -- require modul dengan aliasing atau destrukturisasi tabel |
| 26 | do | 26 | do |
| 27 | import "player" as PlayerModule | 27 | import "player" as PlayerModule |
| 28 | import "lpeg" as :C, :Ct, :Cmt | 28 | import "lpeg" as :C, :Ct, :Cmt |
| @@ -31,24 +31,24 @@ do | |||
| 31 | <YueDisplay> | 31 | <YueDisplay> |
| 32 | 32 | ||
| 33 | ```yue | 33 | ```yue |
| 34 | -- used as table destructuring | 34 | -- digunakan sebagai destrukturisasi tabel |
| 35 | do | 35 | do |
| 36 | import insert, concat from table | 36 | import insert, concat from table |
| 37 | -- report error when assigning to insert, concat | 37 | -- akan error saat meng-assign ke insert, concat |
| 38 | import C, Ct, Cmt from require "lpeg" | 38 | import C, Ct, Cmt from require "lpeg" |
| 39 | -- shortcut for implicit requiring | 39 | -- shortcut untuk require implisit |
| 40 | import x, y, z from 'mymodule' | 40 | import x, y, z from 'mymodule' |
| 41 | -- import with Python style | 41 | -- import gaya Python |
| 42 | from 'module' import a, b, c | 42 | from 'module' import a, b, c |
| 43 | 43 | ||
| 44 | -- shortcut for requring a module | 44 | -- shortcut untuk require modul |
| 45 | do | 45 | do |
| 46 | import 'module' | 46 | import 'module' |
| 47 | import 'module_x' | 47 | import 'module_x' |
| 48 | import "d-a-s-h-e-s" | 48 | import "d-a-s-h-e-s" |
| 49 | import "module.part" | 49 | import "module.part" |
| 50 | 50 | ||
| 51 | -- requring module with aliasing or table destructuring | 51 | -- require modul dengan aliasing atau destrukturisasi tabel |
| 52 | do | 52 | do |
| 53 | import "player" as PlayerModule | 53 | import "player" as PlayerModule |
| 54 | import "lpeg" as :C, :Ct, :Cmt | 54 | import "lpeg" as :C, :Ct, :Cmt |
| @@ -59,7 +59,7 @@ do | |||
| 59 | 59 | ||
| 60 | ## Import Global | 60 | ## Import Global |
| 61 | 61 | ||
| 62 | You can import specific globals into local variables with `import`. When importing a chain of global variable accessings, the last field will be assigned to the local variable. | 62 | Anda dapat mengimpor global tertentu ke variabel local dengan `import`. Saat mengimpor rangkaian akses variabel global, field terakhir akan di-assign ke variabel local. |
| 63 | 63 | ||
| 64 | ```yuescript | 64 | ```yuescript |
| 65 | do | 65 | do |
| @@ -78,11 +78,11 @@ do | |||
| 78 | 78 | ||
| 79 | </YueDisplay> | 79 | </YueDisplay> |
| 80 | 80 | ||
| 81 | ### Automatic Global Variable Import | 81 | ### Import Variabel Global Otomatis |
| 82 | 82 | ||
| 83 | You can place `import global` at the top of a block to automatically import all names that have not been explicitly declared or assigned in the current scope as globals. These implicit imports are treated as local consts that reference the corresponding globals at the position of the statement. | 83 | Anda dapat menempatkan `import global` di awal blok untuk mengimpor secara otomatis semua nama yang belum dideklarasikan atau di-assign secara eksplisit di scope saat ini sebagai global. Import implisit ini diperlakukan sebagai local const yang mereferensikan global terkait pada posisi pernyataan tersebut. |
| 84 | 84 | ||
| 85 | Names that are explicitly declared as globals in the same scope will not be imported, so you can still assign to them. | 85 | Nama yang secara eksplisit dideklarasikan sebagai global di scope yang sama tidak akan diimpor, sehingga Anda masih bisa meng-assign ke mereka. |
| 86 | 86 | ||
| 87 | ```yuescript | 87 | ```yuescript |
| 88 | do | 88 | do |
| @@ -92,7 +92,7 @@ do | |||
| 92 | -- print = nil -- error: imported globals are const | 92 | -- print = nil -- error: imported globals are const |
| 93 | 93 | ||
| 94 | do | 94 | do |
| 95 | -- explicit global variable will not be imported | 95 | -- variabel global eksplisit tidak akan diimpor |
| 96 | import global | 96 | import global |
| 97 | global FLAG | 97 | global FLAG |
| 98 | print FLAG | 98 | print FLAG |
| @@ -108,7 +108,7 @@ do | |||
| 108 | -- print = nil -- error: imported globals are const | 108 | -- print = nil -- error: imported globals are const |
| 109 | 109 | ||
| 110 | do | 110 | do |
| 111 | -- explicit global variable will not be imported | 111 | -- variabel global eksplisit tidak akan diimpor |
| 112 | import global | 112 | import global |
| 113 | global FLAG | 113 | global FLAG |
| 114 | print FLAG | 114 | print FLAG |
| @@ -119,11 +119,11 @@ do | |||
| 119 | 119 | ||
| 120 | ## Export | 120 | ## Export |
| 121 | 121 | ||
| 122 | The export statement offers a concise way to define modules. | 122 | Pernyataan `export` menawarkan cara ringkas untuk mendefinisikan modul. |
| 123 | 123 | ||
| 124 | ### Named Export | 124 | ### Export Bernama |
| 125 | 125 | ||
| 126 | Named export will define a local variable as well as adding a field in the exported table. | 126 | Export bernama akan mendefinisikan variabel local sekaligus menambahkan field di tabel export. |
| 127 | 127 | ||
| 128 | ```yuescript | 128 | ```yuescript |
| 129 | export a, b, c = 1, 2, 3 | 129 | export a, b, c = 1, 2, 3 |
| @@ -160,7 +160,7 @@ export class Something | |||
| 160 | 160 | ||
| 161 | </YueDisplay> | 161 | </YueDisplay> |
| 162 | 162 | ||
| 163 | Doing named export with destructuring. | 163 | Melakukan export bernama dengan destrukturisasi. |
| 164 | 164 | ||
| 165 | ```yuescript | 165 | ```yuescript |
| 166 | export :loadstring, to_lua: tolua = yue | 166 | export :loadstring, to_lua: tolua = yue |
| @@ -175,7 +175,7 @@ export {itemA: {:fieldA = 'default'}} = tb | |||
| 175 | 175 | ||
| 176 | </YueDisplay> | 176 | </YueDisplay> |
| 177 | 177 | ||
| 178 | Export named items from module without creating local variables. | 178 | Export item bernama dari modul tanpa membuat variabel local. |
| 179 | 179 | ||
| 180 | ```yuescript | 180 | ```yuescript |
| 181 | export.itemA = tb | 181 | export.itemA = tb |
| @@ -192,9 +192,9 @@ export["a-b-c"] = 123 | |||
| 192 | 192 | ||
| 193 | </YueDisplay> | 193 | </YueDisplay> |
| 194 | 194 | ||
| 195 | ### Unnamed Export | 195 | ### Export Tanpa Nama |
| 196 | 196 | ||
| 197 | Unnamed export will add the target item into the array part of the exported table. | 197 | Export tanpa nama akan menambahkan item target ke bagian array dari tabel export. |
| 198 | 198 | ||
| 199 | ```yuescript | 199 | ```yuescript |
| 200 | d, e, f = 3, 2, 1 | 200 | d, e, f = 3, 2, 1 |
| @@ -225,9 +225,9 @@ export with tmp | |||
| 225 | 225 | ||
| 226 | </YueDisplay> | 226 | </YueDisplay> |
| 227 | 227 | ||
| 228 | ### Default Export | 228 | ### Export Default |
| 229 | 229 | ||
| 230 | Using the **default** keyword in export statement to replace the exported table with any thing. | 230 | Gunakan kata kunci **default** dalam pernyataan export untuk mengganti tabel export dengan apa pun. |
| 231 | 231 | ||
| 232 | ```yuescript | 232 | ```yuescript |
| 233 | export default -> | 233 | export default -> |
diff --git a/doc/docs/id-id/doc/advanced/try.md b/doc/docs/id-id/doc/advanced/try.md index 23c7877..6607451 100644 --- a/doc/docs/id-id/doc/advanced/try.md +++ b/doc/docs/id-id/doc/advanced/try.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Try | 1 | # Try |
| 2 | 2 | ||
| 3 | The syntax for Lua error handling in a common form. | 3 | Sintaks untuk penanganan error Lua dalam bentuk umum. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | try | 6 | try |
| @@ -23,7 +23,7 @@ try | |||
| 23 | print "trying" | 23 | print "trying" |
| 24 | func 1, 2, 3 | 24 | func 1, 2, 3 |
| 25 | 25 | ||
| 26 | -- working with if assignment pattern | 26 | -- bekerja dengan pola if assignment |
| 27 | if success, result := try func 1, 2, 3 | 27 | if success, result := try func 1, 2, 3 |
| 28 | catch err | 28 | catch err |
| 29 | print yue.traceback err | 29 | print yue.traceback err |
| @@ -52,7 +52,7 @@ try | |||
| 52 | print "trying" | 52 | print "trying" |
| 53 | func 1, 2, 3 | 53 | func 1, 2, 3 |
| 54 | 54 | ||
| 55 | -- working with if assignment pattern | 55 | -- bekerja dengan pola if assignment |
| 56 | if success, result := try func 1, 2, 3 | 56 | if success, result := try func 1, 2, 3 |
| 57 | catch err | 57 | catch err |
| 58 | print yue.traceback err | 58 | print yue.traceback err |
| @@ -63,18 +63,18 @@ catch err | |||
| 63 | 63 | ||
| 64 | ## Try? | 64 | ## Try? |
| 65 | 65 | ||
| 66 | `try?` is a simplified use for error handling syntax that omit the boolean status from the `try` statement, and it will return the result from the try block when success, return nil instead of error object otherwise. | 66 | `try?` adalah bentuk sederhana untuk penanganan error yang menghilangkan status boolean dari pernyataan `try`, dan akan mengembalikan hasil dari blok try ketika berhasil, atau mengembalikan nil alih-alih objek error bila gagal. |
| 67 | 67 | ||
| 68 | ```yuescript | 68 | ```yuescript |
| 69 | a, b, c = try? func! | 69 | a, b, c = try? func! |
| 70 | 70 | ||
| 71 | -- with nil coalescing operator | 71 | -- dengan operator nil coalescing |
| 72 | a = (try? func!) ?? "default" | 72 | a = (try? func!) ?? "default" |
| 73 | 73 | ||
| 74 | -- as function argument | 74 | -- sebagai argumen fungsi |
| 75 | f try? func! | 75 | f try? func! |
| 76 | 76 | ||
| 77 | -- with catch block | 77 | -- dengan blok catch |
| 78 | f try? | 78 | f try? |
| 79 | print 123 | 79 | print 123 |
| 80 | func! | 80 | func! |
| @@ -87,13 +87,13 @@ catch e | |||
| 87 | ```yue | 87 | ```yue |
| 88 | a, b, c = try? func! | 88 | a, b, c = try? func! |
| 89 | 89 | ||
| 90 | -- with nil coalescing operator | 90 | -- dengan operator nil coalescing |
| 91 | a = (try? func!) ?? "default" | 91 | a = (try? func!) ?? "default" |
| 92 | 92 | ||
| 93 | -- as function argument | 93 | -- sebagai argumen fungsi |
| 94 | f try? func! | 94 | f try? func! |
| 95 | 95 | ||
| 96 | -- with catch block | 96 | -- dengan blok catch |
| 97 | f try? | 97 | f try? |
| 98 | print 123 | 98 | print 123 |
| 99 | func! | 99 | func! |
diff --git a/doc/docs/id-id/doc/assignment/assignment.md b/doc/docs/id-id/doc/assignment/assignment.md index 4dac6f4..d9fd45d 100644 --- a/doc/docs/id-id/doc/assignment/assignment.md +++ b/doc/docs/id-id/doc/assignment/assignment.md | |||
| @@ -1,25 +1,25 @@ | |||
| 1 | # Assignment | 1 | # Penugasan |
| 2 | 2 | ||
| 3 | The variable is dynamic typed and is defined as local by default. But you can change the scope of declaration by **local** and **global** statement. | 3 | Variabel bersifat bertipe dinamis dan secara default dideklarasikan sebagai local. Namun Anda dapat mengubah cakupan deklarasi dengan pernyataan **local** dan **global**. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | hello = "world" | 6 | hello = "world" |
| 7 | a, b, c = 1, 2, 3 | 7 | a, b, c = 1, 2, 3 |
| 8 | hello = 123 -- uses the existing variable | 8 | hello = 123 -- menggunakan variabel yang sudah ada |
| 9 | ``` | 9 | ``` |
| 10 | <YueDisplay> | 10 | <YueDisplay> |
| 11 | 11 | ||
| 12 | ```yue | 12 | ```yue |
| 13 | hello = "world" | 13 | hello = "world" |
| 14 | a, b, c = 1, 2, 3 | 14 | a, b, c = 1, 2, 3 |
| 15 | hello = 123 -- uses the existing variable | 15 | hello = 123 -- menggunakan variabel yang sudah ada |
| 16 | ``` | 16 | ``` |
| 17 | 17 | ||
| 18 | </YueDisplay> | 18 | </YueDisplay> |
| 19 | 19 | ||
| 20 | ## Perform Update | 20 | ## Pembaruan Nilai |
| 21 | 21 | ||
| 22 | You can perform update assignment with many binary operators. | 22 | Anda dapat melakukan assignment pembaruan dengan banyak operator biner. |
| 23 | ```yuescript | 23 | ```yuescript |
| 24 | x = 1 | 24 | x = 1 |
| 25 | x += 1 | 25 | x += 1 |
| @@ -27,7 +27,7 @@ x -= 1 | |||
| 27 | x *= 10 | 27 | x *= 10 |
| 28 | x /= 10 | 28 | x /= 10 |
| 29 | x %= 10 | 29 | x %= 10 |
| 30 | s ..= "world" -- will add a new local if local variable is not exist | 30 | s ..= "world" -- akan menambah local baru jika variabel local belum ada |
| 31 | arg or= "default value" | 31 | arg or= "default value" |
| 32 | ``` | 32 | ``` |
| 33 | <YueDisplay> | 33 | <YueDisplay> |
| @@ -39,15 +39,15 @@ x -= 1 | |||
| 39 | x *= 10 | 39 | x *= 10 |
| 40 | x /= 10 | 40 | x /= 10 |
| 41 | x %= 10 | 41 | x %= 10 |
| 42 | s ..= "world" -- will add a new local if local variable is not exist | 42 | s ..= "world" -- akan menambah local baru jika variabel local belum ada |
| 43 | arg or= "default value" | 43 | arg or= "default value" |
| 44 | ``` | 44 | ``` |
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | ## Chaining Assignment | 48 | ## Assignment Berantai |
| 49 | 49 | ||
| 50 | You can do chaining assignment to assign multiple items to hold the same value. | 50 | Anda bisa melakukan assignment berantai untuk menetapkan beberapa item ke nilai yang sama. |
| 51 | ```yuescript | 51 | ```yuescript |
| 52 | a = b = c = d = e = 0 | 52 | a = b = c = d = e = 0 |
| 53 | x = y = z = f! | 53 | x = y = z = f! |
| @@ -61,12 +61,12 @@ x = y = z = f! | |||
| 61 | 61 | ||
| 62 | </YueDisplay> | 62 | </YueDisplay> |
| 63 | 63 | ||
| 64 | ## Explicit Locals | 64 | ## Local Eksplisit |
| 65 | ```yuescript | 65 | ```yuescript |
| 66 | do | 66 | do |
| 67 | local a = 1 | 67 | local a = 1 |
| 68 | local * | 68 | local * |
| 69 | print "forward declare all variables as locals" | 69 | print "deklarasikan semua variabel sebagai local di awal" |
| 70 | x = -> 1 + y + z | 70 | x = -> 1 + y + z |
| 71 | y, z = 2, 3 | 71 | y, z = 2, 3 |
| 72 | global instance = Item\new! | 72 | global instance = Item\new! |
| @@ -74,7 +74,7 @@ do | |||
| 74 | do | 74 | do |
| 75 | local X = 1 | 75 | local X = 1 |
| 76 | local ^ | 76 | local ^ |
| 77 | print "only forward declare upper case variables" | 77 | print "hanya deklarasikan variabel huruf besar sebagai local di awal" |
| 78 | a = 1 | 78 | a = 1 |
| 79 | B = 2 | 79 | B = 2 |
| 80 | ``` | 80 | ``` |
| @@ -84,7 +84,7 @@ do | |||
| 84 | do | 84 | do |
| 85 | local a = 1 | 85 | local a = 1 |
| 86 | local * | 86 | local * |
| 87 | print "forward declare all variables as locals" | 87 | print "deklarasikan semua variabel sebagai local di awal" |
| 88 | x = -> 1 + y + z | 88 | x = -> 1 + y + z |
| 89 | y, z = 2, 3 | 89 | y, z = 2, 3 |
| 90 | global instance = Item\new! | 90 | global instance = Item\new! |
| @@ -92,26 +92,26 @@ do | |||
| 92 | do | 92 | do |
| 93 | local X = 1 | 93 | local X = 1 |
| 94 | local ^ | 94 | local ^ |
| 95 | print "only forward declare upper case variables" | 95 | print "hanya deklarasikan variabel huruf besar sebagai local di awal" |
| 96 | a = 1 | 96 | a = 1 |
| 97 | B = 2 | 97 | B = 2 |
| 98 | ``` | 98 | ``` |
| 99 | 99 | ||
| 100 | </YueDisplay> | 100 | </YueDisplay> |
| 101 | 101 | ||
| 102 | ## Explicit Globals | 102 | ## Global Eksplisit |
| 103 | ```yuescript | 103 | ```yuescript |
| 104 | do | 104 | do |
| 105 | global a = 1 | 105 | global a = 1 |
| 106 | global * | 106 | global * |
| 107 | print "declare all variables as globals" | 107 | print "deklarasikan semua variabel sebagai global" |
| 108 | x = -> 1 + y + z | 108 | x = -> 1 + y + z |
| 109 | y, z = 2, 3 | 109 | y, z = 2, 3 |
| 110 | 110 | ||
| 111 | do | 111 | do |
| 112 | global X = 1 | 112 | global X = 1 |
| 113 | global ^ | 113 | global ^ |
| 114 | print "only declare upper case variables as globals" | 114 | print "hanya deklarasikan variabel huruf besar sebagai global" |
| 115 | a = 1 | 115 | a = 1 |
| 116 | B = 2 | 116 | B = 2 |
| 117 | local Temp = "a local value" | 117 | local Temp = "a local value" |
| @@ -122,14 +122,14 @@ do | |||
| 122 | do | 122 | do |
| 123 | global a = 1 | 123 | global a = 1 |
| 124 | global * | 124 | global * |
| 125 | print "declare all variables as globals" | 125 | print "deklarasikan semua variabel sebagai global" |
| 126 | x = -> 1 + y + z | 126 | x = -> 1 + y + z |
| 127 | y, z = 2, 3 | 127 | y, z = 2, 3 |
| 128 | 128 | ||
| 129 | do | 129 | do |
| 130 | global X = 1 | 130 | global X = 1 |
| 131 | global ^ | 131 | global ^ |
| 132 | print "only declare upper case variables as globals" | 132 | print "hanya deklarasikan variabel huruf besar sebagai global" |
| 133 | a = 1 | 133 | a = 1 |
| 134 | B = 2 | 134 | B = 2 |
| 135 | local Temp = "a local value" | 135 | local Temp = "a local value" |
diff --git a/doc/docs/id-id/doc/assignment/destructuring-assignment.md b/doc/docs/id-id/doc/assignment/destructuring-assignment.md index e7b8046..ba591fd 100644 --- a/doc/docs/id-id/doc/assignment/destructuring-assignment.md +++ b/doc/docs/id-id/doc/assignment/destructuring-assignment.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Destructuring Assignment | 1 | # Penugasan Destrukturisasi |
| 2 | 2 | ||
| 3 | Destructuring assignment is a way to quickly extract values from a table by their name or position in array based tables. | 3 | Assignment destrukturisasi adalah cara cepat untuk mengekstrak nilai dari sebuah tabel berdasarkan nama kunci atau posisinya pada tabel berbasis array. |
| 4 | 4 | ||
| 5 | Typically when you see a table literal, {1,2,3}, it is on the right hand side of an assignment because it is a value. Destructuring assignment swaps the role of the table literal, and puts it on the left hand side of an assign statement. | 5 | Biasanya ketika Anda melihat literal tabel, `{1,2,3}`, ia berada di sisi kanan assignment karena merupakan nilai. Assignment destrukturisasi menukar peran literal tabel dan menaruhnya di sisi kiri pernyataan assignment. |
| 6 | 6 | ||
| 7 | This is best explained with examples. Here is how you would unpack the first two values from a table: | 7 | Ini paling mudah dijelaskan dengan contoh. Berikut cara membongkar dua nilai pertama dari sebuah tabel: |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | thing = [1, 2] | 10 | thing = [1, 2] |
| @@ -23,7 +23,7 @@ print a, b | |||
| 23 | 23 | ||
| 24 | </YueDisplay> | 24 | </YueDisplay> |
| 25 | 25 | ||
| 26 | In the destructuring table literal, the key represents the key to read from the right hand side, and the value represents the name the read value will be assigned to. | 26 | Di literal tabel destrukturisasi, kunci mewakili kunci yang dibaca dari sisi kanan, dan nilai mewakili nama yang akan menerima nilai tersebut. |
| 27 | 27 | ||
| 28 | ```yuescript | 28 | ```yuescript |
| 29 | obj = { | 29 | obj = { |
| @@ -35,7 +35,7 @@ obj = { | |||
| 35 | {hello: hello, day: the_day} = obj | 35 | {hello: hello, day: the_day} = obj |
| 36 | print hello, the_day | 36 | print hello, the_day |
| 37 | 37 | ||
| 38 | :day = obj -- OK to do simple destructuring without braces | 38 | :day = obj -- OK untuk destrukturisasi sederhana tanpa kurung |
| 39 | ``` | 39 | ``` |
| 40 | <YueDisplay> | 40 | <YueDisplay> |
| 41 | 41 | ||
| @@ -49,12 +49,12 @@ obj = { | |||
| 49 | {hello: hello, day: the_day} = obj | 49 | {hello: hello, day: the_day} = obj |
| 50 | print hello, the_day | 50 | print hello, the_day |
| 51 | 51 | ||
| 52 | :day = obj -- OK to do simple destructuring without braces | 52 | :day = obj -- OK untuk destrukturisasi sederhana tanpa kurung |
| 53 | ``` | 53 | ``` |
| 54 | 54 | ||
| 55 | </YueDisplay> | 55 | </YueDisplay> |
| 56 | 56 | ||
| 57 | This also works with nested data structures as well: | 57 | Ini juga bekerja pada struktur data bertingkat: |
| 58 | 58 | ||
| 59 | ```yuescript | 59 | ```yuescript |
| 60 | obj2 = { | 60 | obj2 = { |
| @@ -85,7 +85,7 @@ print first, second, color | |||
| 85 | 85 | ||
| 86 | </YueDisplay> | 86 | </YueDisplay> |
| 87 | 87 | ||
| 88 | If the destructuring statement is complicated, feel free to spread it out over a few lines. A slightly more complicated example: | 88 | Jika pernyataan destrukturisasi kompleks, Anda bisa memecahnya ke beberapa baris. Contoh yang sedikit lebih rumit: |
| 89 | 89 | ||
| 90 | ```yuescript | 90 | ```yuescript |
| 91 | { | 91 | { |
| @@ -108,7 +108,7 @@ If the destructuring statement is complicated, feel free to spread it out over a | |||
| 108 | 108 | ||
| 109 | </YueDisplay> | 109 | </YueDisplay> |
| 110 | 110 | ||
| 111 | It's common to extract values from at table and assign them the local variables that have the same name as the key. In order to avoid repetition we can use the **:** prefix operator: | 111 | Umumnya mengekstrak nilai dari tabel lalu menugaskannya ke variabel local dengan nama yang sama dengan kuncinya. Untuk menghindari pengulangan, kita bisa menggunakan operator prefiks **:**: |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | {:concat, :insert} = table | 114 | {:concat, :insert} = table |
| @@ -121,7 +121,7 @@ It's common to extract values from at table and assign them the local variables | |||
| 121 | 121 | ||
| 122 | </YueDisplay> | 122 | </YueDisplay> |
| 123 | 123 | ||
| 124 | This is effectively the same as import, but we can rename fields we want to extract by mixing the syntax: | 124 | Ini secara efektif sama seperti import, tetapi kita dapat mengganti nama field yang ingin diekstrak dengan menggabungkan sintaks: |
| 125 | 125 | ||
| 126 | ```yuescript | 126 | ```yuescript |
| 127 | {:mix, :max, random: rand} = math | 127 | {:mix, :max, random: rand} = math |
| @@ -134,7 +134,7 @@ This is effectively the same as import, but we can rename fields we want to extr | |||
| 134 | 134 | ||
| 135 | </YueDisplay> | 135 | </YueDisplay> |
| 136 | 136 | ||
| 137 | You can write default values while doing destructuring like: | 137 | Anda bisa menulis nilai default saat destrukturisasi seperti: |
| 138 | 138 | ||
| 139 | ```yuescript | 139 | ```yuescript |
| 140 | {:name = "nameless", :job = "jobless"} = person | 140 | {:name = "nameless", :job = "jobless"} = person |
| @@ -147,7 +147,7 @@ You can write default values while doing destructuring like: | |||
| 147 | 147 | ||
| 148 | </YueDisplay> | 148 | </YueDisplay> |
| 149 | 149 | ||
| 150 | You can use `_` as placeholder when doing a list destructuring: | 150 | Anda dapat menggunakan `_` sebagai placeholder saat destrukturisasi list: |
| 151 | 151 | ||
| 152 | ```yuescript | 152 | ```yuescript |
| 153 | [_, two, _, four] = items | 153 | [_, two, _, four] = items |
| @@ -160,9 +160,9 @@ You can use `_` as placeholder when doing a list destructuring: | |||
| 160 | 160 | ||
| 161 | </YueDisplay> | 161 | </YueDisplay> |
| 162 | 162 | ||
| 163 | ## Range Destructuring | 163 | ## Destrukturisasi Rentang |
| 164 | 164 | ||
| 165 | You can use the spread operator `...` in list destructuring to capture a range of values. This is useful when you want to extract specific elements from the beginning and end of a list while collecting the rest in between. | 165 | Anda dapat menggunakan operator spread `...` pada destrukturisasi list untuk menangkap rentang nilai. Ini berguna ketika Anda ingin mengekstrak elemen tertentu dari awal dan akhir list sambil mengumpulkan sisanya di tengah. |
| 166 | 166 | ||
| 167 | ```yuescript | 167 | ```yuescript |
| 168 | orders = ["first", "second", "third", "fourth", "last"] | 168 | orders = ["first", "second", "third", "fourth", "last"] |
| @@ -183,36 +183,36 @@ print last -- prints: last | |||
| 183 | 183 | ||
| 184 | </YueDisplay> | 184 | </YueDisplay> |
| 185 | 185 | ||
| 186 | The spread operator can be used in different positions to capture different ranges, and you can use `_` as a placeholder for the values you don't want to capture: | 186 | Operator spread dapat digunakan pada posisi berbeda untuk menangkap rentang yang berbeda, dan Anda bisa memakai `_` sebagai placeholder untuk nilai yang tidak ingin ditangkap: |
| 187 | 187 | ||
| 188 | ```yuescript | 188 | ```yuescript |
| 189 | -- Capture everything after first element | 189 | -- Tangkap semuanya setelah elemen pertama |
| 190 | [first, ...rest] = orders | 190 | [first, ...rest] = orders |
| 191 | 191 | ||
| 192 | -- Capture everything before last element | 192 | -- Tangkap semuanya sebelum elemen terakhir |
| 193 | [...start, last] = orders | 193 | [...start, last] = orders |
| 194 | 194 | ||
| 195 | -- Capture things except the middle elements | 195 | -- Tangkap semuanya kecuali elemen tengah |
| 196 | [first, ..._, last] = orders | 196 | [first, ..._, last] = orders |
| 197 | ``` | 197 | ``` |
| 198 | <YueDisplay> | 198 | <YueDisplay> |
| 199 | 199 | ||
| 200 | ```yue | 200 | ```yue |
| 201 | -- Capture everything after first element | 201 | -- Tangkap semuanya setelah elemen pertama |
| 202 | [first, ...rest] = orders | 202 | [first, ...rest] = orders |
| 203 | 203 | ||
| 204 | -- Capture everything before last element | 204 | -- Tangkap semuanya sebelum elemen terakhir |
| 205 | [...start, last] = orders | 205 | [...start, last] = orders |
| 206 | 206 | ||
| 207 | -- Capture things except the middle elements | 207 | -- Tangkap semuanya kecuali elemen tengah |
| 208 | [first, ..._, last] = orders | 208 | [first, ..._, last] = orders |
| 209 | ``` | 209 | ``` |
| 210 | 210 | ||
| 211 | </YueDisplay> | 211 | </YueDisplay> |
| 212 | 212 | ||
| 213 | ## Destructuring In Other Places | 213 | ## Destrukturisasi di Tempat Lain |
| 214 | 214 | ||
| 215 | Destructuring can also show up in places where an assignment implicitly takes place. An example of this is a for loop: | 215 | Destrukturisasi juga dapat muncul di tempat-tempat di mana assignment terjadi secara implisit. Contohnya adalah perulangan for: |
| 216 | 216 | ||
| 217 | ```yuescript | 217 | ```yuescript |
| 218 | tuples = [ | 218 | tuples = [ |
| @@ -237,4 +237,4 @@ for [left, right] in *tuples | |||
| 237 | 237 | ||
| 238 | </YueDisplay> | 238 | </YueDisplay> |
| 239 | 239 | ||
| 240 | We know each element in the array table is a two item tuple, so we can unpack it directly in the names clause of the for statement using a destructure. | 240 | Kita tahu setiap elemen pada tabel array adalah tuple dua item, sehingga kita dapat membongkarnya langsung di klausa nama pada pernyataan for menggunakan destrukturisasi. |
diff --git a/doc/docs/id-id/doc/assignment/if-assignment.md b/doc/docs/id-id/doc/assignment/if-assignment.md index 02984e8..b30d0d9 100644 --- a/doc/docs/id-id/doc/assignment/if-assignment.md +++ b/doc/docs/id-id/doc/assignment/if-assignment.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # If Assignment | 1 | # Penugasan pada If |
| 2 | 2 | ||
| 3 | `if` and `elseif` blocks can take an assignment in place of a conditional expression. Upon evaluating the conditional, the assignment will take place and the value that was assigned to will be used as the conditional expression. The assigned variable is only in scope for the body of the conditional, meaning it is never available if the value is not truthy. And you have to use "the walrus operator" `:=` instead of `=` to do assignment. | 3 | Blok `if` dan `elseif` dapat menerima assignment sebagai ganti ekspresi kondisional. Saat kondisi dievaluasi, assignment akan dilakukan dan nilai yang di-assign akan digunakan sebagai ekspresi kondisional. Variabel yang di-assign hanya berada dalam scope badan kondisional, artinya tidak pernah tersedia jika nilai tidak truthy. Dan Anda harus menggunakan "walrus operator" `:=` sebagai ganti `=` untuk melakukan assignment. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | if user := database.find_user "moon" | 6 | if user := database.find_user "moon" |
| @@ -36,36 +36,36 @@ else | |||
| 36 | 36 | ||
| 37 | </YueDisplay> | 37 | </YueDisplay> |
| 38 | 38 | ||
| 39 | If assignment with multiple return values. Only the first value is getting checked, other values are scoped. | 39 | Assignment if dengan beberapa nilai return. Hanya nilai pertama yang dicek, nilai lainnya tetap berada dalam scope. |
| 40 | ```yuescript | 40 | ```yuescript |
| 41 | if success, result := pcall -> "get result without problems" | 41 | if success, result := pcall -> "get result without problems" |
| 42 | print result -- variable result is scoped | 42 | print result -- variabel result berada dalam scope |
| 43 | print "OK" | 43 | print "OK" |
| 44 | ``` | 44 | ``` |
| 45 | <YueDisplay> | 45 | <YueDisplay> |
| 46 | 46 | ||
| 47 | ```yue | 47 | ```yue |
| 48 | if success, result := pcall -> "get result without problems" | 48 | if success, result := pcall -> "get result without problems" |
| 49 | print result -- variable result is scoped | 49 | print result -- variabel result berada dalam scope |
| 50 | print "OK" | 50 | print "OK" |
| 51 | ``` | 51 | ``` |
| 52 | 52 | ||
| 53 | </YueDisplay> | 53 | </YueDisplay> |
| 54 | 54 | ||
| 55 | ## While Assignment | 55 | ## Assignment pada While |
| 56 | 56 | ||
| 57 | You can also use if assignment in a while loop to get the value as the loop condition. | 57 | Anda juga bisa menggunakan assignment if di loop while untuk mendapatkan nilai sebagai kondisi loop. |
| 58 | 58 | ||
| 59 | ```yuescript | 59 | ```yuescript |
| 60 | while byte := stream\read_one! | 60 | while byte := stream\read_one! |
| 61 | -- do something with the byte | 61 | -- lakukan sesuatu dengan byte |
| 62 | print byte | 62 | print byte |
| 63 | ``` | 63 | ``` |
| 64 | <YueDisplay> | 64 | <YueDisplay> |
| 65 | 65 | ||
| 66 | ```yue | 66 | ```yue |
| 67 | while byte := stream\read_one! | 67 | while byte := stream\read_one! |
| 68 | -- do something with the byte | 68 | -- lakukan sesuatu dengan byte |
| 69 | print byte | 69 | print byte |
| 70 | ``` | 70 | ``` |
| 71 | 71 | ||
diff --git a/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md index fb9b740..6953138 100644 --- a/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md +++ b/doc/docs/id-id/doc/assignment/the-using-clause-controlling-destructive-assignment.md | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | # The Using Clause; Controlling Destructive Assignment | 1 | # Klausa Using; Mengendalikan Penugasan Destruktif |
| 2 | 2 | ||
| 3 | While lexical scoping can be a great help in reducing the complexity of the code we write, things can get unwieldy as the code size increases. Consider the following snippet: | 3 | Meskipun scope leksikal sangat membantu mengurangi kompleksitas kode yang kita tulis, hal ini bisa menjadi sulit ketika ukuran kode membesar. Pertimbangkan cuplikan berikut: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 100 | 6 | i = 100 |
| 7 | 7 | ||
| 8 | -- many lines of code... | 8 | -- banyak baris kode... |
| 9 | 9 | ||
| 10 | my_func = -> | 10 | my_func = -> |
| 11 | i = 10 | 11 | i = 10 |
| @@ -15,14 +15,14 @@ my_func = -> | |||
| 15 | 15 | ||
| 16 | my_func! | 16 | my_func! |
| 17 | 17 | ||
| 18 | print i -- will print 0 | 18 | print i -- akan mencetak 0 |
| 19 | ``` | 19 | ``` |
| 20 | <YueDisplay> | 20 | <YueDisplay> |
| 21 | 21 | ||
| 22 | ```yue | 22 | ```yue |
| 23 | i = 100 | 23 | i = 100 |
| 24 | 24 | ||
| 25 | -- many lines of code... | 25 | -- banyak baris kode... |
| 26 | 26 | ||
| 27 | my_func = -> | 27 | my_func = -> |
| 28 | i = 10 | 28 | i = 10 |
| @@ -32,25 +32,25 @@ my_func = -> | |||
| 32 | 32 | ||
| 33 | my_func! | 33 | my_func! |
| 34 | 34 | ||
| 35 | print i -- will print 0 | 35 | print i -- akan mencetak 0 |
| 36 | ``` | 36 | ``` |
| 37 | 37 | ||
| 38 | </YueDisplay> | 38 | </YueDisplay> |
| 39 | 39 | ||
| 40 | In my_func, we've overwritten the value of i mistakenly. In this example it is quite obvious, but consider a large, or foreign code base where it isn't clear what names have already been declared. | 40 | Di `my_func`, kita tanpa sengaja menimpa nilai `i`. Dalam contoh ini halnya cukup jelas, tetapi bayangkan kode besar atau basis kode asing di mana tidak jelas nama apa saja yang sudah dideklarasikan. |
| 41 | 41 | ||
| 42 | It would be helpful to say which variables from the enclosing scope we intend on change, in order to prevent us from changing others by accident. | 42 | Akan sangat membantu jika kita dapat menyatakan variabel mana dari scope luar yang memang ingin kita ubah, agar mencegah mengubah yang lain secara tidak sengaja. |
| 43 | 43 | ||
| 44 | The using keyword lets us do that. using nil makes sure that no closed variables are overwritten in assignment. The using clause is placed after the argument list in a function, or in place of it if there are no arguments. | 44 | Kata kunci `using` memungkinkan kita melakukan itu. `using nil` memastikan bahwa tidak ada variabel tertutup yang ditimpa dalam assignment. Klausa `using` ditempatkan setelah daftar argumen pada fungsi, atau menggantikannya jika tidak ada argumen. |
| 45 | 45 | ||
| 46 | ```yuescript | 46 | ```yuescript |
| 47 | i = 100 | 47 | i = 100 |
| 48 | 48 | ||
| 49 | my_func = (using nil) -> | 49 | my_func = (using nil) -> |
| 50 | i = "hello" -- a new local variable is created here | 50 | i = "hello" -- variabel local baru dibuat di sini |
| 51 | 51 | ||
| 52 | my_func! | 52 | my_func! |
| 53 | print i -- prints 100, i is unaffected | 53 | print i -- mencetak 100, i tidak terpengaruh |
| 54 | ``` | 54 | ``` |
| 55 | <YueDisplay> | 55 | <YueDisplay> |
| 56 | 56 | ||
| @@ -58,27 +58,27 @@ print i -- prints 100, i is unaffected | |||
| 58 | i = 100 | 58 | i = 100 |
| 59 | 59 | ||
| 60 | my_func = (using nil) -> | 60 | my_func = (using nil) -> |
| 61 | i = "hello" -- a new local variable is created here | 61 | i = "hello" -- variabel local baru dibuat di sini |
| 62 | 62 | ||
| 63 | my_func! | 63 | my_func! |
| 64 | print i -- prints 100, i is unaffected | 64 | print i -- mencetak 100, i tidak terpengaruh |
| 65 | ``` | 65 | ``` |
| 66 | 66 | ||
| 67 | </YueDisplay> | 67 | </YueDisplay> |
| 68 | 68 | ||
| 69 | Multiple names can be separated by commas. Closure values can still be accessed, they just cant be modified: | 69 | Beberapa nama dapat dipisahkan dengan koma. Nilai closure tetap bisa diakses, hanya saja tidak dapat dimodifikasi: |
| 70 | 70 | ||
| 71 | ```yuescript | 71 | ```yuescript |
| 72 | tmp = 1213 | 72 | tmp = 1213 |
| 73 | i, k = 100, 50 | 73 | i, k = 100, 50 |
| 74 | 74 | ||
| 75 | my_func = (add using k, i) -> | 75 | my_func = (add using k, i) -> |
| 76 | tmp = tmp + add -- a new local tmp is created | 76 | tmp = tmp + add -- tmp local baru dibuat |
| 77 | i += tmp | 77 | i += tmp |
| 78 | k += tmp | 78 | k += tmp |
| 79 | 79 | ||
| 80 | my_func(22) | 80 | my_func(22) |
| 81 | print i, k -- these have been updated | 81 | print i, k -- ini telah diperbarui |
| 82 | ``` | 82 | ``` |
| 83 | <YueDisplay> | 83 | <YueDisplay> |
| 84 | 84 | ||
| @@ -87,12 +87,12 @@ tmp = 1213 | |||
| 87 | i, k = 100, 50 | 87 | i, k = 100, 50 |
| 88 | 88 | ||
| 89 | my_func = (add using k, i) -> | 89 | my_func = (add using k, i) -> |
| 90 | tmp = tmp + add -- a new local tmp is created | 90 | tmp = tmp + add -- tmp local baru dibuat |
| 91 | i += tmp | 91 | i += tmp |
| 92 | k += tmp | 92 | k += tmp |
| 93 | 93 | ||
| 94 | my_func(22) | 94 | my_func(22) |
| 95 | print i, k -- these have been updated | 95 | print i, k -- ini telah diperbarui |
| 96 | ``` | 96 | ``` |
| 97 | 97 | ||
| 98 | </YueDisplay> | 98 | </YueDisplay> |
diff --git a/doc/docs/id-id/doc/assignment/varargs-assignment.md b/doc/docs/id-id/doc/assignment/varargs-assignment.md index 1d66680..f24652f 100644 --- a/doc/docs/id-id/doc/assignment/varargs-assignment.md +++ b/doc/docs/id-id/doc/assignment/varargs-assignment.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Varargs Assignment | 1 | # Penugasan Varargs |
| 2 | 2 | ||
| 3 | You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. | 3 | Anda dapat meng-assign hasil yang dikembalikan dari sebuah fungsi ke simbol varargs `...`. Lalu akses isinya menggunakan cara Lua. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | list = [1, 2, 3, 4, 5] | 6 | list = [1, 2, 3, 4, 5] |
diff --git a/doc/docs/id-id/doc/control-flow/conditionals.md b/doc/docs/id-id/doc/control-flow/conditionals.md index 5ba81cf..4f08b16 100644 --- a/doc/docs/id-id/doc/control-flow/conditionals.md +++ b/doc/docs/id-id/doc/control-flow/conditionals.md | |||
| @@ -1,55 +1,55 @@ | |||
| 1 | # Conditionals | 1 | # Kondisional |
| 2 | 2 | ||
| 3 | ```yuescript | 3 | ```yuescript |
| 4 | have_coins = false | 4 | have_coins = false |
| 5 | if have_coins | 5 | if have_coins |
| 6 | print "Got coins" | 6 | print "Dapat koin" |
| 7 | else | 7 | else |
| 8 | print "No coins" | 8 | print "Tidak ada koin" |
| 9 | ``` | 9 | ``` |
| 10 | <YueDisplay> | 10 | <YueDisplay> |
| 11 | 11 | ||
| 12 | ```yue | 12 | ```yue |
| 13 | have_coins = false | 13 | have_coins = false |
| 14 | if have_coins | 14 | if have_coins |
| 15 | print "Got coins" | 15 | print "Dapat koin" |
| 16 | else | 16 | else |
| 17 | print "No coins" | 17 | print "Tidak ada koin" |
| 18 | ``` | 18 | ``` |
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | A short syntax for single statements can also be used: | 22 | Sintaks pendek untuk pernyataan tunggal juga bisa digunakan: |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | have_coins = false | 25 | have_coins = false |
| 26 | if have_coins then print "Got coins" else print "No coins" | 26 | if have_coins then print "Dapat koin" else print "Tidak ada koin" |
| 27 | ``` | 27 | ``` |
| 28 | <YueDisplay> | 28 | <YueDisplay> |
| 29 | 29 | ||
| 30 | ```yue | 30 | ```yue |
| 31 | have_coins = false | 31 | have_coins = false |
| 32 | if have_coins then print "Got coins" else print "No coins" | 32 | if have_coins then print "Dapat koin" else print "Tidak ada koin" |
| 33 | ``` | 33 | ``` |
| 34 | 34 | ||
| 35 | </YueDisplay> | 35 | </YueDisplay> |
| 36 | 36 | ||
| 37 | Because if statements can be used as expressions, this can also be written as: | 37 | Karena pernyataan if dapat digunakan sebagai ekspresi, ini juga bisa ditulis sebagai: |
| 38 | 38 | ||
| 39 | ```yuescript | 39 | ```yuescript |
| 40 | have_coins = false | 40 | have_coins = false |
| 41 | print if have_coins then "Got coins" else "No coins" | 41 | print if have_coins then "Dapat koin" else "Tidak ada koin" |
| 42 | ``` | 42 | ``` |
| 43 | <YueDisplay> | 43 | <YueDisplay> |
| 44 | 44 | ||
| 45 | ```yue | 45 | ```yue |
| 46 | have_coins = false | 46 | have_coins = false |
| 47 | print if have_coins then "Got coins" else "No coins" | 47 | print if have_coins then "Dapat koin" else "Tidak ada koin" |
| 48 | ``` | 48 | ``` |
| 49 | 49 | ||
| 50 | </YueDisplay> | 50 | </YueDisplay> |
| 51 | 51 | ||
| 52 | Conditionals can also be used in return statements and assignments: | 52 | Kondisional juga bisa digunakan di pernyataan return dan assignment: |
| 53 | 53 | ||
| 54 | ```yuescript | 54 | ```yuescript |
| 55 | is_tall = (name) -> | 55 | is_tall = (name) -> |
| @@ -59,11 +59,11 @@ is_tall = (name) -> | |||
| 59 | false | 59 | false |
| 60 | 60 | ||
| 61 | message = if is_tall "Rob" | 61 | message = if is_tall "Rob" |
| 62 | "I am very tall" | 62 | "Saya sangat tinggi" |
| 63 | else | 63 | else |
| 64 | "I am not so tall" | 64 | "Saya tidak terlalu tinggi" |
| 65 | 65 | ||
| 66 | print message -- prints: I am very tall | 66 | print message -- prints: Saya sangat tinggi |
| 67 | ``` | 67 | ``` |
| 68 | <YueDisplay> | 68 | <YueDisplay> |
| 69 | 69 | ||
| @@ -75,53 +75,53 @@ is_tall = (name) -> | |||
| 75 | false | 75 | false |
| 76 | 76 | ||
| 77 | message = if is_tall "Rob" | 77 | message = if is_tall "Rob" |
| 78 | "I am very tall" | 78 | "Saya sangat tinggi" |
| 79 | else | 79 | else |
| 80 | "I am not so tall" | 80 | "Saya tidak terlalu tinggi" |
| 81 | 81 | ||
| 82 | print message -- prints: I am very tall | 82 | print message -- prints: Saya sangat tinggi |
| 83 | ``` | 83 | ``` |
| 84 | 84 | ||
| 85 | </YueDisplay> | 85 | </YueDisplay> |
| 86 | 86 | ||
| 87 | The opposite of if is unless: | 87 | Kebalikan dari if adalah unless: |
| 88 | 88 | ||
| 89 | ```yuescript | 89 | ```yuescript |
| 90 | unless os.date("%A") == "Monday" | 90 | unless os.date("%A") == "Monday" |
| 91 | print "it is not Monday!" | 91 | print "hari ini bukan Senin!" |
| 92 | ``` | 92 | ``` |
| 93 | <YueDisplay> | 93 | <YueDisplay> |
| 94 | 94 | ||
| 95 | ```yue | 95 | ```yue |
| 96 | unless os.date("%A") == "Monday" | 96 | unless os.date("%A") == "Monday" |
| 97 | print "it is not Monday!" | 97 | print "hari ini bukan Senin!" |
| 98 | ``` | 98 | ``` |
| 99 | 99 | ||
| 100 | </YueDisplay> | 100 | </YueDisplay> |
| 101 | 101 | ||
| 102 | ```yuescript | 102 | ```yuescript |
| 103 | print "You're lucky!" unless math.random! > 0.1 | 103 | print "Kamu beruntung!" unless math.random! > 0.1 |
| 104 | ``` | 104 | ``` |
| 105 | <YueDisplay> | 105 | <YueDisplay> |
| 106 | 106 | ||
| 107 | ```yue | 107 | ```yue |
| 108 | print "You're lucky!" unless math.random! > 0.1 | 108 | print "Kamu beruntung!" unless math.random! > 0.1 |
| 109 | ``` | 109 | ``` |
| 110 | 110 | ||
| 111 | </YueDisplay> | 111 | </YueDisplay> |
| 112 | 112 | ||
| 113 | ## In Expression | 113 | ## Ekspresi In |
| 114 | 114 | ||
| 115 | You can write range checking code with an `in-expression`. | 115 | Anda dapat menulis kode pengecekan rentang dengan `ekspresi in`. |
| 116 | 116 | ||
| 117 | ```yuescript | 117 | ```yuescript |
| 118 | a = 5 | 118 | a = 5 |
| 119 | 119 | ||
| 120 | if a in [1, 3, 5, 7] | 120 | if a in [1, 3, 5, 7] |
| 121 | print "checking equality with discrete values" | 121 | print "memeriksa kesamaan dengan nilai-nilai diskrit" |
| 122 | 122 | ||
| 123 | if a in list | 123 | if a in list |
| 124 | print "checking if `a` is in a list" | 124 | print "memeriksa apakah `a` ada di dalam daftar" |
| 125 | ``` | 125 | ``` |
| 126 | <YueDisplay> | 126 | <YueDisplay> |
| 127 | 127 | ||
| @@ -129,21 +129,10 @@ if a in list | |||
| 129 | a = 5 | 129 | a = 5 |
| 130 | 130 | ||
| 131 | if a in [1, 3, 5, 7] | 131 | if a in [1, 3, 5, 7] |
| 132 | print "checking equality with discrete values" | 132 | print "memeriksa kesamaan dengan nilai-nilai diskrit" |
| 133 | 133 | ||
| 134 | if a in list | 134 | if a in list |
| 135 | print "checking if `a` is in a list" | 135 | print "memeriksa apakah `a` ada di dalam daftar" |
| 136 | ``` | ||
| 137 | |||
| 138 | </YueDisplay> | ||
| 139 | |||
| 140 | ```yuescript | ||
| 141 | print "You're lucky!" unless math.random! > 0.1 | ||
| 142 | ``` | ||
| 143 | <YueDisplay> | ||
| 144 | |||
| 145 | ```yue | ||
| 146 | print "You're lucky!" unless math.random! > 0.1 | ||
| 147 | ``` | 136 | ``` |
| 148 | 137 | ||
| 149 | </YueDisplay> | 138 | </YueDisplay> |
diff --git a/doc/docs/id-id/doc/control-flow/continue.md b/doc/docs/id-id/doc/control-flow/continue.md index b000765..3d7a68c 100644 --- a/doc/docs/id-id/doc/control-flow/continue.md +++ b/doc/docs/id-id/doc/control-flow/continue.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Continue | 1 | # Pernyataan Continue |
| 2 | 2 | ||
| 3 | A continue statement can be used to skip the current iteration in a loop. | 3 | Pernyataan continue dapat digunakan untuk melewati iterasi saat ini di dalam loop. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 0 | 6 | i = 0 |
| @@ -21,7 +21,7 @@ while i < 10 | |||
| 21 | 21 | ||
| 22 | </YueDisplay> | 22 | </YueDisplay> |
| 23 | 23 | ||
| 24 | continue can also be used with loop expressions to prevent that iteration from accumulating into the result. This examples filters the array table into just even numbers: | 24 | continue juga bisa digunakan bersama ekspresi loop untuk mencegah iterasi tersebut diakumulasikan ke hasil. Contoh ini memfilter tabel array menjadi hanya angka genap: |
| 25 | 25 | ||
| 26 | ```yuescript | 26 | ```yuescript |
| 27 | my_numbers = [1, 2, 3, 4, 5, 6] | 27 | my_numbers = [1, 2, 3, 4, 5, 6] |
diff --git a/doc/docs/id-id/doc/control-flow/for-loop.md b/doc/docs/id-id/doc/control-flow/for-loop.md index cabcde5..91ba22e 100644 --- a/doc/docs/id-id/doc/control-flow/for-loop.md +++ b/doc/docs/id-id/doc/control-flow/for-loop.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # For Loop | 1 | # Perulangan For |
| 2 | 2 | ||
| 3 | There are two for loop forms, just like in Lua. A numeric one and a generic one: | 3 | Ada dua bentuk perulangan for, seperti di Lua. Satu numerik dan satu generik: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | for i = 10, 20 | 6 | for i = 10, 20 |
| @@ -27,7 +27,7 @@ for key, value in pairs object | |||
| 27 | 27 | ||
| 28 | </YueDisplay> | 28 | </YueDisplay> |
| 29 | 29 | ||
| 30 | The slicing and **\*** operators can be used, just like with comprehensions: | 30 | Operator slicing dan **\*** dapat digunakan, seperti pada comprehension: |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | for item in *items[2, 4] | 33 | for item in *items[2, 4] |
| @@ -42,7 +42,7 @@ for item in *items[2, 4] | |||
| 42 | 42 | ||
| 43 | </YueDisplay> | 43 | </YueDisplay> |
| 44 | 44 | ||
| 45 | A shorter syntax is also available for all variations when the body is only a single line: | 45 | Sintaks yang lebih singkat juga tersedia untuk semua variasi ketika badan hanya satu baris: |
| 46 | 46 | ||
| 47 | ```yuescript | 47 | ```yuescript |
| 48 | for item in *items do print item | 48 | for item in *items do print item |
| @@ -59,9 +59,9 @@ for j = 1, 10, 3 do print j | |||
| 59 | 59 | ||
| 60 | </YueDisplay> | 60 | </YueDisplay> |
| 61 | 61 | ||
| 62 | A for loop can also be used as an expression. The last statement in the body of the for loop is coerced into an expression and appended to an accumulating array table. | 62 | Perulangan for juga bisa digunakan sebagai ekspresi. Pernyataan terakhir di badan for dipaksa menjadi ekspresi dan ditambahkan ke tabel array yang terakumulasi. |
| 63 | 63 | ||
| 64 | Doubling every even number: | 64 | Menggandakan setiap bilangan genap: |
| 65 | 65 | ||
| 66 | ```yuescript | 66 | ```yuescript |
| 67 | doubled_evens = for i = 1, 20 | 67 | doubled_evens = for i = 1, 20 |
| @@ -82,9 +82,9 @@ doubled_evens = for i = 1, 20 | |||
| 82 | 82 | ||
| 83 | </YueDisplay> | 83 | </YueDisplay> |
| 84 | 84 | ||
| 85 | In addition, for loops support break with a return value, allowing the loop itself to be used as an expression that exits early with a meaningful result. | 85 | Selain itu, loop for mendukung break dengan nilai kembalian, sehingga loop itu sendiri bisa dipakai sebagai ekspresi yang keluar lebih awal dengan hasil bermakna. |
| 86 | 86 | ||
| 87 | For example, to find the first number greater than 10: | 87 | Contohnya, untuk menemukan angka pertama yang lebih besar dari 10: |
| 88 | 88 | ||
| 89 | ```yuescript | 89 | ```yuescript |
| 90 | first_large = for n in *numbers | 90 | first_large = for n in *numbers |
| @@ -99,11 +99,11 @@ first_large = for n in *numbers | |||
| 99 | 99 | ||
| 100 | </YueDisplay> | 100 | </YueDisplay> |
| 101 | 101 | ||
| 102 | This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. | 102 | Sintaks break-dengan-nilai ini memungkinkan pola pencarian atau keluar-lebih-awal yang ringkas langsung di dalam ekspresi loop. |
| 103 | 103 | ||
| 104 | You can also filter values by combining the for loop expression with the continue statement. | 104 | Anda juga bisa memfilter nilai dengan menggabungkan ekspresi for dengan pernyataan continue. |
| 105 | 105 | ||
| 106 | For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension. | 106 | Loop for di akhir badan fungsi tidak diakumulasikan menjadi tabel untuk nilai kembalian (sebaliknya fungsi akan mengembalikan nil). Gunakan pernyataan return eksplisit, atau ubah loop menjadi list comprehension. |
| 107 | 107 | ||
| 108 | ```yuescript | 108 | ```yuescript |
| 109 | func_a = -> for i = 1, 10 do print i | 109 | func_a = -> for i = 1, 10 do print i |
| @@ -123,5 +123,3 @@ print func_b! -- prints table object | |||
| 123 | ``` | 123 | ``` |
| 124 | 124 | ||
| 125 | </YueDisplay> | 125 | </YueDisplay> |
| 126 | |||
| 127 | This is done to avoid the needless creation of tables for functions that don't need to return the results of the loop. | ||
diff --git a/doc/docs/id-id/doc/control-flow/switch.md b/doc/docs/id-id/doc/control-flow/switch.md index f503a80..ced4748 100644 --- a/doc/docs/id-id/doc/control-flow/switch.md +++ b/doc/docs/id-id/doc/control-flow/switch.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Switch | 1 | # Pernyataan Switch |
| 2 | 2 | ||
| 3 | The switch statement is shorthand for writing a series of if statements that check against the same value. Note that the value is only evaluated once. Like if statements, switches can have an else block to handle no matches. Comparison is done with the == operator. In switch statement, you can also use assignment expression to store temporary variable value. | 3 | Pernyataan switch adalah bentuk singkat untuk menulis serangkaian if yang membandingkan nilai yang sama. Perhatikan bahwa nilainya hanya dievaluasi sekali. Seperti if, switch bisa memiliki blok else untuk menangani tidak ada yang cocok. Perbandingan dilakukan dengan operator `==`. Di dalam switch, Anda juga bisa memakai ekspresi assignment untuk menyimpan nilai variabel sementara. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | switch name := "Dan" | 6 | switch name := "Dan" |
| @@ -25,9 +25,9 @@ switch name := "Dan" | |||
| 25 | 25 | ||
| 26 | </YueDisplay> | 26 | </YueDisplay> |
| 27 | 27 | ||
| 28 | A switch when clause can match against multiple values by listing them out comma separated. | 28 | Klausa when pada switch bisa mencocokkan beberapa nilai dengan menuliskannya dipisah koma. |
| 29 | 29 | ||
| 30 | Switches can be used as expressions as well, here we can assign the result of the switch to a variable: | 30 | Switch juga bisa dipakai sebagai ekspresi; di sini kita dapat menetapkan hasil switch ke sebuah variabel: |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | b = 1 | 33 | b = 1 |
| @@ -54,7 +54,7 @@ next_number = switch b | |||
| 54 | 54 | ||
| 55 | </YueDisplay> | 55 | </YueDisplay> |
| 56 | 56 | ||
| 57 | We can use the then keyword to write a switch's when block on a single line. No extra keyword is needed to write the else block on a single line. | 57 | Kita bisa memakai kata kunci `then` untuk menulis blok when switch pada satu baris. Tidak ada kata kunci tambahan yang dibutuhkan untuk menulis blok else pada satu baris. |
| 58 | 58 | ||
| 59 | ```yuescript | 59 | ```yuescript |
| 60 | msg = switch math.random(1, 5) | 60 | msg = switch math.random(1, 5) |
| @@ -73,7 +73,7 @@ msg = switch math.random(1, 5) | |||
| 73 | 73 | ||
| 74 | </YueDisplay> | 74 | </YueDisplay> |
| 75 | 75 | ||
| 76 | If you want to write code with one less indent when writing a switch statement, you can put the first when clause on the statement start line, and then all other clauses can be written with one less indent. | 76 | Jika Anda ingin menulis kode dengan satu indentasi lebih sedikit saat menulis switch, Anda bisa menaruh klausa when pertama pada baris awal pernyataan, lalu semua klausa lain dapat ditulis dengan satu indentasi lebih sedikit. |
| 77 | 77 | ||
| 78 | ```yuescript | 78 | ```yuescript |
| 79 | switch math.random(1, 5) | 79 | switch math.random(1, 5) |
| @@ -104,11 +104,11 @@ else | |||
| 104 | 104 | ||
| 105 | </YueDisplay> | 105 | </YueDisplay> |
| 106 | 106 | ||
| 107 | It is worth noting the order of the case comparison expression. The case's expression is on the left hand side. This can be useful if the case's expression wants to overwrite how the comparison is done by defining an eq metamethod. | 107 | Perlu dicatat urutan ekspresi perbandingan kasus. Ekspresi kasus berada di sisi kiri. Ini bisa berguna jika ekspresi kasus ingin mengganti cara perbandingan dengan mendefinisikan metamethod `eq`. |
| 108 | 108 | ||
| 109 | ## Table Matching | 109 | ## Pencocokan Tabel |
| 110 | 110 | ||
| 111 | You can do table matching in a switch when clause, if the table can be destructured by a specific structure and get non-nil values. | 111 | Anda bisa melakukan pencocokan tabel dalam klausa when switch, jika tabel dapat didestrukturisasi oleh struktur tertentu dan mendapatkan nilai non-nil. |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | items = | 114 | items = |
| @@ -143,7 +143,7 @@ for item in *items | |||
| 143 | 143 | ||
| 144 | </YueDisplay> | 144 | </YueDisplay> |
| 145 | 145 | ||
| 146 | You can use default values to optionally destructure the table for some fields. | 146 | Anda dapat menggunakan nilai default untuk mendestrukturisasi tabel secara opsional pada beberapa field. |
| 147 | 147 | ||
| 148 | ```yuescript | 148 | ```yuescript |
| 149 | item = {} | 149 | item = {} |
| @@ -168,9 +168,9 @@ switch item | |||
| 168 | 168 | ||
| 169 | </YueDisplay> | 169 | </YueDisplay> |
| 170 | 170 | ||
| 171 | You can also match against array elements, table fields, and even nested structures with array or table literals. | 171 | Anda juga bisa mencocokkan elemen array, field tabel, dan bahkan struktur bertingkat dengan literal array atau tabel. |
| 172 | 172 | ||
| 173 | Match against array elements. | 173 | Cocokkan terhadap elemen array. |
| 174 | 174 | ||
| 175 | ```yuescript | 175 | ```yuescript |
| 176 | switch tb | 176 | switch tb |
| @@ -195,7 +195,7 @@ switch tb | |||
| 195 | 195 | ||
| 196 | </YueDisplay> | 196 | </YueDisplay> |
| 197 | 197 | ||
| 198 | Match against table fields with destructuring. | 198 | Cocokkan terhadap field tabel dengan destrukturisasi. |
| 199 | 199 | ||
| 200 | ```yuescript | 200 | ```yuescript |
| 201 | switch tb | 201 | switch tb |
| @@ -220,7 +220,7 @@ switch tb | |||
| 220 | 220 | ||
| 221 | </YueDisplay> | 221 | </YueDisplay> |
| 222 | 222 | ||
| 223 | Match against nested table structures. | 223 | Cocokkan terhadap struktur tabel bertingkat. |
| 224 | 224 | ||
| 225 | ```yuescript | 225 | ```yuescript |
| 226 | switch tb | 226 | switch tb |
| @@ -245,7 +245,7 @@ switch tb | |||
| 245 | 245 | ||
| 246 | </YueDisplay> | 246 | </YueDisplay> |
| 247 | 247 | ||
| 248 | Match against array of tables. | 248 | Cocokkan terhadap array dari tabel. |
| 249 | 249 | ||
| 250 | ```yuescript | 250 | ```yuescript |
| 251 | switch tb | 251 | switch tb |
| @@ -272,7 +272,7 @@ switch tb | |||
| 272 | 272 | ||
| 273 | </YueDisplay> | 273 | </YueDisplay> |
| 274 | 274 | ||
| 275 | Match against a list and capture a range of elements. | 275 | Cocokkan terhadap daftar dan tangkap rentang elemen. |
| 276 | 276 | ||
| 277 | ```yuescript | 277 | ```yuescript |
| 278 | segments = ["admin", "users", "logs", "view"] | 278 | segments = ["admin", "users", "logs", "view"] |
diff --git a/doc/docs/id-id/doc/control-flow/while-loop.md b/doc/docs/id-id/doc/control-flow/while-loop.md index 502935e..cd93c91 100644 --- a/doc/docs/id-id/doc/control-flow/while-loop.md +++ b/doc/docs/id-id/doc/control-flow/while-loop.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # While Loop | 1 | # Perulangan While |
| 2 | 2 | ||
| 3 | The while loop also comes in four variations: | 3 | Perulangan while juga memiliki empat variasi: |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | i = 10 | 6 | i = 10 |
| @@ -43,11 +43,11 @@ until running == false do my_function! | |||
| 43 | 43 | ||
| 44 | </YueDisplay> | 44 | </YueDisplay> |
| 45 | 45 | ||
| 46 | Like for loops, the while loop can also be used an expression. Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned. | 46 | Seperti loop for, loop while juga bisa digunakan sebagai ekspresi. Selain itu, agar sebuah fungsi mengembalikan nilai akumulasi dari loop while, pernyataannya harus di-return secara eksplisit. |
| 47 | 47 | ||
| 48 | ## Repeat Loop | 48 | ## Repeat Loop |
| 49 | 49 | ||
| 50 | The repeat loop comes from Lua: | 50 | Loop repeat berasal dari Lua: |
| 51 | 51 | ||
| 52 | ```yuescript | 52 | ```yuescript |
| 53 | i = 10 | 53 | i = 10 |
diff --git a/doc/docs/id-id/doc/data-structures/comprehensions.md b/doc/docs/id-id/doc/data-structures/comprehensions.md index 3a92167..3a2a9ff 100644 --- a/doc/docs/id-id/doc/data-structures/comprehensions.md +++ b/doc/docs/id-id/doc/data-structures/comprehensions.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Comprehensions | 1 | # Komprehensi |
| 2 | 2 | ||
| 3 | Comprehensions provide a convenient syntax for constructing a new table by iterating over some existing object and applying an expression to its values. There are two kinds of comprehensions: list comprehensions and table comprehensions. They both produce Lua tables; list comprehensions accumulate values into an array-like table, and table comprehensions let you set both the key and the value on each iteration. | 3 | Komprehensi menyediakan sintaks yang nyaman untuk membangun tabel baru dengan mengiterasi objek yang ada dan menerapkan ekspresi pada nilainya. Ada dua jenis komprehensi: komprehensi list dan komprehensi tabel. Keduanya menghasilkan tabel Lua; komprehensi list mengakumulasi nilai ke tabel mirip array, dan komprehensi tabel memungkinkan Anda menetapkan kunci dan nilai pada setiap iterasi. |
| 4 | 4 | ||
| 5 | ## List Comprehensions | 5 | ## Komprehensi List |
| 6 | 6 | ||
| 7 | The following creates a copy of the items table but with all the values doubled. | 7 | Berikut membuat salinan tabel `items` tetapi semua nilainya digandakan. |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | items = [ 1, 2, 3, 4 ] | 10 | items = [ 1, 2, 3, 4 ] |
| @@ -19,7 +19,7 @@ doubled = [item * 2 for i, item in ipairs items] | |||
| 19 | 19 | ||
| 20 | </YueDisplay> | 20 | </YueDisplay> |
| 21 | 21 | ||
| 22 | The items included in the new table can be restricted with a when clause: | 22 | Item yang disertakan dalam tabel baru bisa dibatasi dengan klausa `when`: |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] | 25 | slice = [item for i, item in ipairs items when i > 1 and i < 3] |
| @@ -32,7 +32,7 @@ slice = [item for i, item in ipairs items when i > 1 and i < 3] | |||
| 32 | 32 | ||
| 33 | </YueDisplay> | 33 | </YueDisplay> |
| 34 | 34 | ||
| 35 | Because it is common to iterate over the values of a numerically indexed table, an **\*** operator is introduced. The doubled example can be rewritten as: | 35 | Karena umum untuk mengiterasi nilai dari tabel berindeks numerik, operator **\*** diperkenalkan. Contoh `doubled` bisa ditulis ulang sebagai: |
| 36 | 36 | ||
| 37 | ```yuescript | 37 | ```yuescript |
| 38 | doubled = [item * 2 for item in *items] | 38 | doubled = [item * 2 for item in *items] |
| @@ -45,7 +45,7 @@ doubled = [item * 2 for item in *items] | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | In list comprehensions, you can also use the spread operator `...` to flatten nested lists, achieving a flat map effect: | 48 | Dalam komprehensi list, Anda juga bisa menggunakan operator spread `...` untuk meratakan list bertingkat, menghasilkan efek flat map: |
| 49 | 49 | ||
| 50 | ```yuescript | 50 | ```yuescript |
| 51 | data = | 51 | data = |
| @@ -53,7 +53,7 @@ data = | |||
| 53 | b: [4, 5, 6] | 53 | b: [4, 5, 6] |
| 54 | 54 | ||
| 55 | flat = [...v for k,v in pairs data] | 55 | flat = [...v for k,v in pairs data] |
| 56 | -- flat is now [1, 2, 3, 4, 5, 6] | 56 | -- flat sekarang [1, 2, 3, 4, 5, 6] |
| 57 | ``` | 57 | ``` |
| 58 | <YueDisplay> | 58 | <YueDisplay> |
| 59 | 59 | ||
| @@ -63,14 +63,14 @@ data = | |||
| 63 | b: [4, 5, 6] | 63 | b: [4, 5, 6] |
| 64 | 64 | ||
| 65 | flat = [...v for k,v in pairs data] | 65 | flat = [...v for k,v in pairs data] |
| 66 | -- flat is now [1, 2, 3, 4, 5, 6] | 66 | -- flat sekarang [1, 2, 3, 4, 5, 6] |
| 67 | ``` | 67 | ``` |
| 68 | 68 | ||
| 69 | </YueDisplay> | 69 | </YueDisplay> |
| 70 | 70 | ||
| 71 | The for and when clauses can be chained as much as desired. The only requirement is that a comprehension has at least one for clause. | 71 | Klausa `for` dan `when` dapat dirantai sebanyak yang diinginkan. Satu-satunya syarat adalah komprehensi memiliki setidaknya satu klausa `for`. |
| 72 | 72 | ||
| 73 | Using multiple for clauses is the same as using nested loops: | 73 | Menggunakan beberapa klausa `for` sama seperti menggunakan loop bertingkat: |
| 74 | 74 | ||
| 75 | ```yuescript | 75 | ```yuescript |
| 76 | x_coords = [4, 5, 6, 7] | 76 | x_coords = [4, 5, 6, 7] |
| @@ -91,7 +91,7 @@ for y in *y_coords] | |||
| 91 | 91 | ||
| 92 | </YueDisplay> | 92 | </YueDisplay> |
| 93 | 93 | ||
| 94 | Numeric for loops can also be used in comprehensions: | 94 | Perulangan for numerik juga bisa digunakan dalam komprehensi: |
| 95 | 95 | ||
| 96 | ```yuescript | 96 | ```yuescript |
| 97 | evens = [i for i = 1, 100 when i % 2 == 0] | 97 | evens = [i for i = 1, 100 when i % 2 == 0] |
| @@ -104,11 +104,11 @@ evens = [i for i = 1, 100 when i % 2 == 0] | |||
| 104 | 104 | ||
| 105 | </YueDisplay> | 105 | </YueDisplay> |
| 106 | 106 | ||
| 107 | ## Table Comprehensions | 107 | ## Komprehensi Tabel |
| 108 | 108 | ||
| 109 | The syntax for table comprehensions is very similar, only differing by using **{** and **}** and taking two values from each iteration. | 109 | Sintaks untuk komprehensi tabel sangat mirip, hanya berbeda dengan penggunaan **{** dan **}** serta mengambil dua nilai dari setiap iterasi. |
| 110 | 110 | ||
| 111 | This example makes a copy of the tablething: | 111 | Contoh ini membuat salinan tabel `thing`: |
| 112 | 112 | ||
| 113 | ```yuescript | 113 | ```yuescript |
| 114 | thing = { | 114 | thing = { |
| @@ -144,7 +144,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"} | |||
| 144 | 144 | ||
| 145 | </YueDisplay> | 145 | </YueDisplay> |
| 146 | 146 | ||
| 147 | The **\*** operator is also supported. Here we create a square root look up table for a few numbers. | 147 | Operator **\*** juga didukung. Di sini kita membuat tabel lookup akar kuadrat untuk beberapa angka. |
| 148 | 148 | ||
| 149 | ```yuescript | 149 | ```yuescript |
| 150 | numbers = [1, 2, 3, 4] | 150 | numbers = [1, 2, 3, 4] |
| @@ -159,9 +159,9 @@ sqrts = {i, math.sqrt i for i in *numbers} | |||
| 159 | 159 | ||
| 160 | </YueDisplay> | 160 | </YueDisplay> |
| 161 | 161 | ||
| 162 | The key-value tuple in a table comprehension can also come from a single expression, in which case the expression should return two values. The first is used as the key and the second is used as the value: | 162 | Tuple key-value dalam komprehensi tabel juga bisa berasal dari satu ekspresi, yang berarti ekspresi tersebut harus mengembalikan dua nilai. Nilai pertama digunakan sebagai kunci dan nilai kedua digunakan sebagai nilai: |
| 163 | 163 | ||
| 164 | In this example we convert an array of pairs to a table where the first item in the pair is the key and the second is the value. | 164 | Dalam contoh ini kita mengonversi array pasangan menjadi tabel di mana item pertama dalam pasangan menjadi kunci dan item kedua menjadi nilai. |
| 165 | 165 | ||
| 166 | ```yuescript | 166 | ```yuescript |
| 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] | 167 | tuples = [ ["hello", "world"], ["foo", "bar"]] |
| @@ -178,9 +178,9 @@ tbl = {unpack tuple for tuple in *tuples} | |||
| 178 | 178 | ||
| 179 | ## Slicing | 179 | ## Slicing |
| 180 | 180 | ||
| 181 | A special syntax is provided to restrict the items that are iterated over when using the **\*** operator. This is equivalent to setting the iteration bounds and a step size in a for loop. | 181 | Sintaks khusus disediakan untuk membatasi item yang diiterasi saat menggunakan operator **\***. Ini setara dengan mengatur batas iterasi dan ukuran langkah pada loop for. |
| 182 | 182 | ||
| 183 | Here we can set the minimum and maximum bounds, taking all items with indexes between 1 and 5 inclusive: | 183 | Di sini kita bisa menetapkan batas minimum dan maksimum, mengambil semua item dengan indeks antara 1 dan 5 (inklusif): |
| 184 | 184 | ||
| 185 | ```yuescript | 185 | ```yuescript |
| 186 | slice = [item for item in *items[1, 5]] | 186 | slice = [item for item in *items[1, 5]] |
| @@ -193,7 +193,7 @@ slice = [item for item in *items[1, 5]] | |||
| 193 | 193 | ||
| 194 | </YueDisplay> | 194 | </YueDisplay> |
| 195 | 195 | ||
| 196 | Any of the slice arguments can be left off to use a sensible default. In this example, if the max index is left off it defaults to the length of the table. This will take everything but the first element: | 196 | Salah satu argumen slice boleh dikosongkan untuk menggunakan default yang masuk akal. Pada contoh ini, jika indeks maksimum dikosongkan, defaultnya adalah panjang tabel. Ini akan mengambil semua item kecuali elemen pertama: |
| 197 | 197 | ||
| 198 | ```yuescript | 198 | ```yuescript |
| 199 | slice = [item for item in *items[2,]] | 199 | slice = [item for item in *items[2,]] |
| @@ -206,7 +206,7 @@ slice = [item for item in *items[2,]] | |||
| 206 | 206 | ||
| 207 | </YueDisplay> | 207 | </YueDisplay> |
| 208 | 208 | ||
| 209 | If the minimum bound is left out, it defaults to 1. Here we only provide a step size and leave the other bounds blank. This takes all odd indexed items: (1, 3, 5, …) | 209 | Jika batas minimum dikosongkan, defaultnya adalah 1. Di sini kita hanya memberikan ukuran langkah dan membiarkan batas lainnya kosong. Ini akan mengambil semua item berindeks ganjil: (1, 3, 5, …) |
| 210 | 210 | ||
| 211 | ```yuescript | 211 | ```yuescript |
| 212 | slice = [item for item in *items[,,2]] | 212 | slice = [item for item in *items[,,2]] |
| @@ -219,22 +219,22 @@ slice = [item for item in *items[,,2]] | |||
| 219 | 219 | ||
| 220 | </YueDisplay> | 220 | </YueDisplay> |
| 221 | 221 | ||
| 222 | Both the minimum and maximum bounds can be negative, which means that the bounds are counted from the end of the table. | 222 | Batas minimum dan maksimum bisa bernilai negatif, yang berarti batas dihitung dari akhir tabel. |
| 223 | 223 | ||
| 224 | ```yuescript | 224 | ```yuescript |
| 225 | -- take the last 4 items | 225 | -- ambil 4 item terakhir |
| 226 | slice = [item for item in *items[-4,-1]] | 226 | slice = [item for item in *items[-4,-1]] |
| 227 | ``` | 227 | ``` |
| 228 | <YueDisplay> | 228 | <YueDisplay> |
| 229 | 229 | ||
| 230 | ```yue | 230 | ```yue |
| 231 | -- take the last 4 items | 231 | -- ambil 4 item terakhir |
| 232 | slice = [item for item in *items[-4,-1]] | 232 | slice = [item for item in *items[-4,-1]] |
| 233 | ``` | 233 | ``` |
| 234 | 234 | ||
| 235 | </YueDisplay> | 235 | </YueDisplay> |
| 236 | 236 | ||
| 237 | The step size can also be negative, which means that the items are taken in reverse order. | 237 | Ukuran langkah juga bisa negatif, yang berarti item diambil dalam urutan terbalik. |
| 238 | 238 | ||
| 239 | ```yuescript | 239 | ```yuescript |
| 240 | reverse_slice = [item for item in *items[-1,1,-1]] | 240 | reverse_slice = [item for item in *items[-1,1,-1]] |
| @@ -247,24 +247,24 @@ reverse_slice = [item for item in *items[-1,1,-1]] | |||
| 247 | 247 | ||
| 248 | </YueDisplay> | 248 | </YueDisplay> |
| 249 | 249 | ||
| 250 | ### Slicing Expression | 250 | ### Ekspresi Slicing |
| 251 | 251 | ||
| 252 | Slicing can also be used as an expression. This is useful for getting a sub-list of a table. | 252 | Slicing juga bisa digunakan sebagai ekspresi. Ini berguna untuk mendapatkan sub-list dari sebuah tabel. |
| 253 | 253 | ||
| 254 | ```yuescript | 254 | ```yuescript |
| 255 | -- take the 2nd and 4th items as a new list | 255 | -- ambil item ke-2 dan ke-4 sebagai list baru |
| 256 | sub_list = items[2, 4] | 256 | sub_list = items[2, 4] |
| 257 | 257 | ||
| 258 | -- take the last 4 items | 258 | -- ambil 4 item terakhir |
| 259 | last_four_items = items[-4, -1] | 259 | last_four_items = items[-4, -1] |
| 260 | ``` | 260 | ``` |
| 261 | <YueDisplay> | 261 | <YueDisplay> |
| 262 | 262 | ||
| 263 | ```yue | 263 | ```yue |
| 264 | -- take the 2nd and 4th items as a new list | 264 | -- ambil item ke-2 dan ke-4 sebagai list baru |
| 265 | sub_list = items[2, 4] | 265 | sub_list = items[2, 4] |
| 266 | 266 | ||
| 267 | -- take the last 4 items | 267 | -- ambil 4 item terakhir |
| 268 | last_four_items = items[-4, -1] | 268 | last_four_items = items[-4, -1] |
| 269 | ``` | 269 | ``` |
| 270 | 270 | ||
diff --git a/doc/docs/id-id/doc/data-structures/table-literals.md b/doc/docs/id-id/doc/data-structures/table-literals.md index c1adcab..df32f1c 100644 --- a/doc/docs/id-id/doc/data-structures/table-literals.md +++ b/doc/docs/id-id/doc/data-structures/table-literals.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Table Literals | 1 | # Literal Tabel |
| 2 | 2 | ||
| 3 | Like in Lua, tables are delimited in curly braces. | 3 | Seperti di Lua, tabel dibatasi dengan kurung kurawal. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | some_values = [1, 2, 3, 4] | 6 | some_values = [1, 2, 3, 4] |
| @@ -13,7 +13,7 @@ some_values = [1, 2, 3, 4] | |||
| 13 | 13 | ||
| 14 | </YueDisplay> | 14 | </YueDisplay> |
| 15 | 15 | ||
| 16 | Unlike Lua, assigning a value to a key in a table is done with **:** (instead of **=**). | 16 | Berbeda dengan Lua, assignment nilai ke sebuah kunci di tabel dilakukan dengan **:** (bukan **=**). |
| 17 | 17 | ||
| 18 | ```yuescript | 18 | ```yuescript |
| 19 | some_values = { | 19 | some_values = { |
| @@ -34,7 +34,7 @@ some_values = { | |||
| 34 | 34 | ||
| 35 | </YueDisplay> | 35 | </YueDisplay> |
| 36 | 36 | ||
| 37 | The curly braces can be left off if a single table of key value pairs is being assigned. | 37 | Kurung kurawal dapat dihilangkan jika hanya satu tabel pasangan key-value yang di-assign. |
| 38 | 38 | ||
| 39 | ```yuescript | 39 | ```yuescript |
| 40 | profile = | 40 | profile = |
| @@ -53,7 +53,7 @@ profile = | |||
| 53 | 53 | ||
| 54 | </YueDisplay> | 54 | </YueDisplay> |
| 55 | 55 | ||
| 56 | Newlines can be used to delimit values instead of a comma (or both): | 56 | Baris baru dapat digunakan untuk memisahkan nilai sebagai ganti koma (atau keduanya): |
| 57 | 57 | ||
| 58 | ```yuescript | 58 | ```yuescript |
| 59 | values = { | 59 | values = { |
| @@ -76,7 +76,7 @@ values = { | |||
| 76 | 76 | ||
| 77 | </YueDisplay> | 77 | </YueDisplay> |
| 78 | 78 | ||
| 79 | When creating a single line table literal, the curly braces can also be left off: | 79 | Saat membuat literal tabel satu baris, kurung kurawal juga bisa dihilangkan: |
| 80 | 80 | ||
| 81 | ```yuescript | 81 | ```yuescript |
| 82 | my_function dance: "Tango", partner: "none" | 82 | my_function dance: "Tango", partner: "none" |
| @@ -93,7 +93,7 @@ y = type: "dog", legs: 4, tails: 1 | |||
| 93 | 93 | ||
| 94 | </YueDisplay> | 94 | </YueDisplay> |
| 95 | 95 | ||
| 96 | The keys of a table literal can be language keywords without being escaped: | 96 | Kunci literal tabel dapat berupa kata kunci bahasa tanpa perlu di-escape: |
| 97 | 97 | ||
| 98 | ```yuescript | 98 | ```yuescript |
| 99 | tbl = { | 99 | tbl = { |
| @@ -112,7 +112,7 @@ tbl = { | |||
| 112 | 112 | ||
| 113 | </YueDisplay> | 113 | </YueDisplay> |
| 114 | 114 | ||
| 115 | If you are constructing a table out of variables and wish the keys to be the same as the variable names, then the **:** prefix operator can be used: | 115 | Jika Anda membangun tabel dari variabel dan ingin kunci sama dengan nama variabel, maka operator prefiks **:** dapat digunakan: |
| 116 | 116 | ||
| 117 | ```yuescript | 117 | ```yuescript |
| 118 | hair = "golden" | 118 | hair = "golden" |
| @@ -133,7 +133,7 @@ print_table :hair, :height | |||
| 133 | 133 | ||
| 134 | </YueDisplay> | 134 | </YueDisplay> |
| 135 | 135 | ||
| 136 | If you want the key of a field in the table to to be result of an expression, then you can wrap it in **[ ]**, just like in Lua. You can also use a string literal directly as a key, leaving out the square brackets. This is useful if your key has any special characters. | 136 | Jika Anda ingin kunci field dalam tabel menjadi hasil suatu ekspresi, Anda dapat membungkusnya dengan **[ ]**, seperti di Lua. Anda juga bisa menggunakan literal string langsung sebagai kunci tanpa tanda kurung siku. Ini berguna jika kunci memiliki karakter khusus. |
| 137 | 137 | ||
| 138 | ```yuescript | 138 | ```yuescript |
| 139 | t = { | 139 | t = { |
| @@ -152,7 +152,7 @@ t = { | |||
| 152 | 152 | ||
| 153 | </YueDisplay> | 153 | </YueDisplay> |
| 154 | 154 | ||
| 155 | Lua tables have both an array part and a hash part, but sometimes you want to make a semantic distinction between array and hash usage when writing Lua tables. Then you can write Lua table with **[ ]** instead of **{ }** to represent an array table and writing any key value pair in a list table won't be allowed. | 155 | Tabel Lua memiliki bagian array dan bagian hash, tetapi terkadang Anda ingin membedakan penggunaan array dan hash secara semantik saat menulis tabel Lua. Maka Anda bisa menulis tabel Lua dengan **[ ]** alih-alih **{ }** untuk merepresentasikan tabel array, dan menuliskan pasangan key-value di tabel list tidak akan diizinkan. |
| 156 | 156 | ||
| 157 | ```yuescript | 157 | ```yuescript |
| 158 | some_values = [1, 2, 3, 4] | 158 | some_values = [1, 2, 3, 4] |
diff --git a/doc/docs/id-id/doc/functions/backcalls.md b/doc/docs/id-id/doc/functions/backcalls.md index e34331e..8d542ee 100644 --- a/doc/docs/id-id/doc/functions/backcalls.md +++ b/doc/docs/id-id/doc/functions/backcalls.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Backcalls | 1 | # Backcall |
| 2 | 2 | ||
| 3 | Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent. | 3 | Backcall digunakan untuk meratakan callback yang bersarang. Backcall didefinisikan menggunakan panah yang mengarah ke kiri sebagai parameter terakhir secara default yang akan mengisi pemanggilan fungsi. Semua sintaks pada dasarnya sama seperti fungsi panah biasa, kecuali arahnya berlawanan dan badan fungsi tidak memerlukan indentasi. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | x <- f | 6 | x <- f |
| @@ -15,7 +15,7 @@ print "hello" .. x | |||
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | Fat arrow functions are also available. | 18 | Fungsi panah tebal juga tersedia. |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | <= f | 21 | <= f |
| @@ -30,7 +30,7 @@ print @value | |||
| 30 | 30 | ||
| 31 | </YueDisplay> | 31 | </YueDisplay> |
| 32 | 32 | ||
| 33 | You can specify a placeholder for where you want the backcall function to go as a parameter. | 33 | Anda dapat menentukan placeholder untuk posisi fungsi backcall sebagai parameter. |
| 34 | 34 | ||
| 35 | ```yuescript | 35 | ```yuescript |
| 36 | (x) <- map _, [1, 2, 3] | 36 | (x) <- map _, [1, 2, 3] |
| @@ -45,7 +45,7 @@ x * 2 | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | If you wish to have further code after your backcalls, you can set them aside with a do statement. And the parentheses can be omitted with non-fat arrow functions. | 48 | Jika Anda ingin menulis kode lanjutan setelah backcall, Anda dapat memisahkannya dengan pernyataan `do`. Tanda kurung dapat dihilangkan untuk fungsi panah non-tebal. |
| 49 | 49 | ||
| 50 | ```yuescript | 50 | ```yuescript |
| 51 | result, msg = do | 51 | result, msg = do |
diff --git a/doc/docs/id-id/doc/functions/function-literals.md b/doc/docs/id-id/doc/functions/function-literals.md index 316e07c..589a26d 100644 --- a/doc/docs/id-id/doc/functions/function-literals.md +++ b/doc/docs/id-id/doc/functions/function-literals.md | |||
| @@ -1,21 +1,21 @@ | |||
| 1 | # Function Literals | 1 | # Literal Fungsi |
| 2 | 2 | ||
| 3 | All functions are created using a function expression. A simple function is denoted using the arrow: **->**. | 3 | Semua fungsi dibuat menggunakan ekspresi fungsi. Fungsi sederhana ditandai dengan panah: **->**. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | my_function = -> | 6 | my_function = -> |
| 7 | my_function() -- call the empty function | 7 | my_function() -- memanggil fungsi kosong |
| 8 | ``` | 8 | ``` |
| 9 | <YueDisplay> | 9 | <YueDisplay> |
| 10 | 10 | ||
| 11 | ```yue | 11 | ```yue |
| 12 | my_function = -> | 12 | my_function = -> |
| 13 | my_function() -- call the empty function | 13 | my_function() -- memanggil fungsi kosong |
| 14 | ``` | 14 | ``` |
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | The body of the function can either be one statement placed directly after the arrow, or it can be a series of statements indented on the following lines: | 18 | Badan fungsi bisa berupa satu pernyataan yang ditulis langsung setelah panah, atau berupa serangkaian pernyataan yang diindentasi di baris berikutnya: |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | func_a = -> print "hello world" | 21 | func_a = -> print "hello world" |
| @@ -36,7 +36,7 @@ func_b = -> | |||
| 36 | 36 | ||
| 37 | </YueDisplay> | 37 | </YueDisplay> |
| 38 | 38 | ||
| 39 | If a function has no arguments, it can be called using the ! operator, instead of empty parentheses. The ! invocation is the preferred way to call functions with no arguments. | 39 | Jika fungsi tidak memiliki argumen, ia dapat dipanggil menggunakan operator `!`, sebagai ganti tanda kurung kosong. Pemanggilan `!` adalah cara yang disarankan untuk memanggil fungsi tanpa argumen. |
| 40 | 40 | ||
| 41 | ```yuescript | 41 | ```yuescript |
| 42 | func_a! | 42 | func_a! |
| @@ -51,7 +51,7 @@ func_b() | |||
| 51 | 51 | ||
| 52 | </YueDisplay> | 52 | </YueDisplay> |
| 53 | 53 | ||
| 54 | Functions with arguments can be created by preceding the arrow with a list of argument names in parentheses: | 54 | Fungsi dengan argumen dapat dibuat dengan menaruh daftar nama argumen dalam tanda kurung sebelum panah: |
| 55 | 55 | ||
| 56 | ```yuescript | 56 | ```yuescript |
| 57 | sum = (x, y) -> print "sum", x + y | 57 | sum = (x, y) -> print "sum", x + y |
| @@ -64,7 +64,7 @@ sum = (x, y) -> print "sum", x + y | |||
| 64 | 64 | ||
| 65 | </YueDisplay> | 65 | </YueDisplay> |
| 66 | 66 | ||
| 67 | Functions can be called by listing the arguments after the name of an expression that evaluates to a function. When chaining together function calls, the arguments are applied to the closest function to the left. | 67 | Fungsi dapat dipanggil dengan menuliskan argumen setelah nama ekspresi yang mengevaluasi ke fungsi. Saat merangkai pemanggilan fungsi, argumen diterapkan ke fungsi terdekat di sebelah kiri. |
| 68 | 68 | ||
| 69 | ```yuescript | 69 | ```yuescript |
| 70 | sum 10, 20 | 70 | sum 10, 20 |
| @@ -83,7 +83,7 @@ a b c "a", "b", "c" | |||
| 83 | 83 | ||
| 84 | </YueDisplay> | 84 | </YueDisplay> |
| 85 | 85 | ||
| 86 | In order to avoid ambiguity in when calling functions, parentheses can also be used to surround the arguments. This is required here in order to make sure the right arguments get sent to the right functions. | 86 | Untuk menghindari ambiguitas saat memanggil fungsi, tanda kurung juga bisa digunakan untuk mengelilingi argumen. Ini diperlukan di sini agar argumen yang tepat dikirim ke fungsi yang tepat. |
| 87 | 87 | ||
| 88 | ```yuescript | 88 | ```yuescript |
| 89 | print "x:", sum(10, 20), "y:", sum(30, 40) | 89 | print "x:", sum(10, 20), "y:", sum(30, 40) |
| @@ -96,9 +96,9 @@ print "x:", sum(10, 20), "y:", sum(30, 40) | |||
| 96 | 96 | ||
| 97 | </YueDisplay> | 97 | </YueDisplay> |
| 98 | 98 | ||
| 99 | There must not be any space between the opening parenthesis and the function. | 99 | Tidak boleh ada spasi antara tanda kurung buka dan nama fungsi. |
| 100 | 100 | ||
| 101 | Functions will coerce the last statement in their body into a return statement, this is called implicit return: | 101 | Fungsi akan memaksa pernyataan terakhir di badannya menjadi pernyataan return, ini disebut return implisit: |
| 102 | 102 | ||
| 103 | ```yuescript | 103 | ```yuescript |
| 104 | sum = (x, y) -> x + y | 104 | sum = (x, y) -> x + y |
| @@ -113,7 +113,7 @@ print "The sum is ", sum 10, 20 | |||
| 113 | 113 | ||
| 114 | </YueDisplay> | 114 | </YueDisplay> |
| 115 | 115 | ||
| 116 | And if you need to explicitly return, you can use the return keyword: | 116 | Dan jika Anda perlu return secara eksplisit, Anda bisa menggunakan kata kunci `return`: |
| 117 | 117 | ||
| 118 | ```yuescript | 118 | ```yuescript |
| 119 | sum = (x, y) -> return x + y | 119 | sum = (x, y) -> return x + y |
| @@ -126,7 +126,7 @@ sum = (x, y) -> return x + y | |||
| 126 | 126 | ||
| 127 | </YueDisplay> | 127 | </YueDisplay> |
| 128 | 128 | ||
| 129 | Just like in Lua, functions can return multiple values. The last statement must be a list of values separated by commas: | 129 | Seperti di Lua, fungsi dapat mengembalikan beberapa nilai. Pernyataan terakhir harus berupa daftar nilai yang dipisahkan koma: |
| 130 | 130 | ||
| 131 | ```yuescript | 131 | ```yuescript |
| 132 | mystery = (x, y) -> x + y, x - y | 132 | mystery = (x, y) -> x + y, x - y |
| @@ -141,9 +141,9 @@ a, b = mystery 10, 20 | |||
| 141 | 141 | ||
| 142 | </YueDisplay> | 142 | </YueDisplay> |
| 143 | 143 | ||
| 144 | ## Fat Arrows | 144 | ## Panah Tebal |
| 145 | 145 | ||
| 146 | Because it is an idiom in Lua to send an object as the first argument when calling a method, a special syntax is provided for creating functions which automatically includes a self argument. | 146 | Karena sudah menjadi idiom di Lua untuk mengirim objek sebagai argumen pertama saat memanggil method, disediakan sintaks khusus untuk membuat fungsi yang otomatis menyertakan argumen `self`. |
| 147 | 147 | ||
| 148 | ```yuescript | 148 | ```yuescript |
| 149 | func = (num) => @value + num | 149 | func = (num) => @value + num |
| @@ -156,9 +156,9 @@ func = (num) => @value + num | |||
| 156 | 156 | ||
| 157 | </YueDisplay> | 157 | </YueDisplay> |
| 158 | 158 | ||
| 159 | ## Argument Defaults | 159 | ## Nilai Default Argumen |
| 160 | 160 | ||
| 161 | It is possible to provide default values for the arguments of a function. An argument is determined to be empty if its value is nil. Any nil arguments that have a default value will be replace before the body of the function is run. | 161 | Dimungkinkan untuk menyediakan nilai default bagi argumen fungsi. Argumen dianggap kosong jika nilainya nil. Argumen nil yang memiliki nilai default akan diganti sebelum badan fungsi dijalankan. |
| 162 | 162 | ||
| 163 | ```yuescript | 163 | ```yuescript |
| 164 | my_function = (name = "something", height = 100) -> | 164 | my_function = (name = "something", height = 100) -> |
| @@ -175,7 +175,7 @@ my_function = (name = "something", height = 100) -> | |||
| 175 | 175 | ||
| 176 | </YueDisplay> | 176 | </YueDisplay> |
| 177 | 177 | ||
| 178 | An argument default value expression is evaluated in the body of the function in the order of the argument declarations. For this reason default values have access to previously declared arguments. | 178 | Ekspresi nilai default argumen dievaluasi di dalam badan fungsi sesuai urutan deklarasi argumen. Karena itu, nilai default dapat mengakses argumen yang dideklarasikan sebelumnya. |
| 179 | 179 | ||
| 180 | ```yuescript | 180 | ```yuescript |
| 181 | some_args = (x = 100, y = x + 1000) -> | 181 | some_args = (x = 100, y = x + 1000) -> |
| @@ -190,11 +190,11 @@ some_args = (x = 100, y = x + 1000) -> | |||
| 190 | 190 | ||
| 191 | </YueDisplay> | 191 | </YueDisplay> |
| 192 | 192 | ||
| 193 | ## Considerations | 193 | ## Pertimbangan |
| 194 | 194 | ||
| 195 | Because of the expressive parentheses-less way of calling functions, some restrictions must be put in place to avoid parsing ambiguity involving whitespace. | 195 | Karena cara pemanggilan fungsi tanpa tanda kurung yang ekspresif, beberapa pembatasan harus diterapkan untuk menghindari ambiguitas parsing yang melibatkan spasi. |
| 196 | 196 | ||
| 197 | The minus sign plays two roles, a unary negation operator and a binary subtraction operator. Consider how the following examples compile: | 197 | Tanda minus memiliki dua peran, operator negasi unari dan operator pengurangan biner. Perhatikan bagaimana contoh berikut dikompilasi: |
| 198 | 198 | ||
| 199 | ```yuescript | 199 | ```yuescript |
| 200 | a = x - 10 | 200 | a = x - 10 |
| @@ -213,11 +213,11 @@ d = x- z | |||
| 213 | 213 | ||
| 214 | </YueDisplay> | 214 | </YueDisplay> |
| 215 | 215 | ||
| 216 | The precedence of the first argument of a function call can be controlled using whitespace if the argument is a literal string. In Lua, it is common to leave off parentheses when calling a function with a single string or table literal. | 216 | Prioritas argumen pertama pada pemanggilan fungsi dapat dikendalikan menggunakan spasi jika argumennya adalah literal string. Di Lua, sudah umum untuk menghilangkan tanda kurung saat memanggil fungsi dengan satu literal string atau tabel. |
| 217 | 217 | ||
| 218 | When there is no space between a variable and a string literal, the function call takes precedence over any following expressions. No other arguments can be passed to the function when it is called this way. | 218 | Ketika tidak ada spasi antara variabel dan literal string, pemanggilan fungsi akan memiliki prioritas atas ekspresi yang mengikuti. Tidak ada argumen lain yang dapat diberikan pada fungsi ketika dipanggil dengan cara ini. |
| 219 | 219 | ||
| 220 | Where there is a space following a variable and a string literal, the function call acts as show above. The string literal belongs to any following expressions (if they exist), which serves as the argument list. | 220 | Ketika ada spasi setelah variabel dan literal string, pemanggilan fungsi bertindak seperti yang dijelaskan di atas. Literal string menjadi milik ekspresi berikutnya (jika ada), yang berfungsi sebagai daftar argumen. |
| 221 | 221 | ||
| 222 | ```yuescript | 222 | ```yuescript |
| 223 | x = func"hello" + 100 | 223 | x = func"hello" + 100 |
| @@ -232,11 +232,11 @@ y = func "hello" + 100 | |||
| 232 | 232 | ||
| 233 | </YueDisplay> | 233 | </YueDisplay> |
| 234 | 234 | ||
| 235 | ## Multi-line arguments | 235 | ## Argumen Multi-baris |
| 236 | 236 | ||
| 237 | When calling functions that take a large number of arguments, it is convenient to split the argument list over multiple lines. Because of the white-space sensitive nature of the language, care must be taken when splitting up the argument list. | 237 | Saat memanggil fungsi yang menerima banyak argumen, akan lebih nyaman untuk memecah daftar argumen menjadi beberapa baris. Karena sifat bahasa yang peka terhadap spasi, perlu hati-hati saat memecah daftar argumen. |
| 238 | 238 | ||
| 239 | If an argument list is to be continued onto the next line, the current line must end in a comma. And the following line must be indented more than the current indentation. Once indented, all other argument lines must be at the same level of indentation to be part of the argument list | 239 | Jika daftar argumen akan dilanjutkan ke baris berikutnya, baris saat ini harus diakhiri dengan koma. Dan baris berikutnya harus lebih terindentasi daripada indentasi saat ini. Setelah diindentasi, semua baris argumen lainnya harus berada pada tingkat indentasi yang sama agar menjadi bagian dari daftar argumen. |
| 240 | 240 | ||
| 241 | ```yuescript | 241 | ```yuescript |
| 242 | my_func 5, 4, 3, | 242 | my_func 5, 4, 3, |
| @@ -261,7 +261,7 @@ cool_func 1, 2, | |||
| 261 | 261 | ||
| 262 | </YueDisplay> | 262 | </YueDisplay> |
| 263 | 263 | ||
| 264 | This type of invocation can be nested. The level of indentation is used to determine to which function the arguments belong to. | 264 | Jenis pemanggilan ini dapat dinest. Tingkat indentasi digunakan untuk menentukan argumen milik fungsi yang mana. |
| 265 | 265 | ||
| 266 | ```yuescript | 266 | ```yuescript |
| 267 | my_func 5, 6, 7, | 267 | my_func 5, 6, 7, |
| @@ -280,7 +280,7 @@ my_func 5, 6, 7, | |||
| 280 | 280 | ||
| 281 | </YueDisplay> | 281 | </YueDisplay> |
| 282 | 282 | ||
| 283 | Because tables also use the comma as a delimiter, this indentation syntax is helpful for letting values be part of the argument list instead of being part of the table. | 283 | Karena tabel juga menggunakan koma sebagai pemisah, sintaks indentasi ini membantu agar nilai menjadi bagian dari daftar argumen, bukan bagian dari tabel. |
| 284 | 284 | ||
| 285 | ```yuescript | 285 | ```yuescript |
| 286 | x = [ | 286 | x = [ |
| @@ -301,7 +301,7 @@ x = [ | |||
| 301 | 301 | ||
| 302 | </YueDisplay> | 302 | </YueDisplay> |
| 303 | 303 | ||
| 304 | Although uncommon, notice how we can give a deeper indentation for function arguments if we know we will be using a lower indentation further on. | 304 | Meskipun jarang, perhatikan bahwa kita bisa memberikan indentasi yang lebih dalam untuk argumen fungsi jika kita tahu akan menggunakan indentasi yang lebih dangkal di bagian selanjutnya. |
| 305 | 305 | ||
| 306 | ```yuescript | 306 | ```yuescript |
| 307 | y = [ my_func 1, 2, 3, | 307 | y = [ my_func 1, 2, 3, |
| @@ -320,7 +320,7 @@ y = [ my_func 1, 2, 3, | |||
| 320 | 320 | ||
| 321 | </YueDisplay> | 321 | </YueDisplay> |
| 322 | 322 | ||
| 323 | The same thing can be done with other block level statements like conditionals. We can use indentation level to determine what statement a value belongs to: | 323 | Hal yang sama juga dapat dilakukan pada pernyataan tingkat blok lainnya seperti kondisional. Kita bisa menggunakan tingkat indentasi untuk menentukan nilai milik pernyataan apa: |
| 324 | 324 | ||
| 325 | ```yuescript | 325 | ```yuescript |
| 326 | if func 1, 2, 3, | 326 | if func 1, 2, 3, |
| @@ -353,13 +353,13 @@ if func 1, 2, 3, | |||
| 353 | 353 | ||
| 354 | </YueDisplay> | 354 | </YueDisplay> |
| 355 | 355 | ||
| 356 | ## Parameter Destructuring | 356 | ## Destrukturisasi Parameter |
| 357 | 357 | ||
| 358 | YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available: | 358 | YueScript kini mendukung destrukturisasi parameter fungsi ketika argumen berupa objek. Dua bentuk destrukturisasi literal tabel tersedia: |
| 359 | 359 | ||
| 360 | * **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`). | 360 | * **Literal berkurung kurawal/parameter objek**, memungkinkan nilai default opsional ketika field hilang (misalnya, `{:a, :b}`, `{a: a1 = 123}`). |
| 361 | 361 | ||
| 362 | * **Unwrapped simple table syntax**, starting with a sequence of key-value or shorthand bindings and continuing until another expression terminates it (e.g., `:a, b: b1, :c`). This form extracts multiple fields from the same object. | 362 | * **Sintaks tabel sederhana tanpa pembungkus**, dimulai dengan urutan key-value atau binding singkat dan berlanjut sampai ekspresi lain menghentikannya (misalnya, `:a, b: b1, :c`). Bentuk ini mengekstrak beberapa field dari objek yang sama. |
| 363 | 363 | ||
| 364 | ```yuescript | 364 | ```yuescript |
| 365 | f1 = (:a, :b, :c) -> | 365 | f1 = (:a, :b, :c) -> |
| @@ -390,9 +390,9 @@ f2 arg1, arg2 | |||
| 390 | 390 | ||
| 391 | </YueDisplay> | 391 | </YueDisplay> |
| 392 | 392 | ||
| 393 | ## Prefixed Return Expression | 393 | ## Ekspresi Return Berawalan |
| 394 | 394 | ||
| 395 | When working with deeply nested function bodies, it can be tedious to maintain readability and consistency of the return value. To address this, YueScript introduces the **Prefixed Return Expression** syntax. Its form is as follows: | 395 | Saat bekerja dengan badan fungsi yang sangat bertingkat, menjaga keterbacaan dan konsistensi nilai return bisa terasa melelahkan. Untuk mengatasinya, YueScript memperkenalkan sintaks **Ekspresi Return Berawalan**. Bentuknya sebagai berikut: |
| 396 | 396 | ||
| 397 | ```yuescript | 397 | ```yuescript |
| 398 | findFirstEven = (list): nil -> | 398 | findFirstEven = (list): nil -> |
| @@ -415,7 +415,7 @@ findFirstEven = (list): nil -> | |||
| 415 | 415 | ||
| 416 | </YueDisplay> | 416 | </YueDisplay> |
| 417 | 417 | ||
| 418 | This is equivalent to: | 418 | Ini setara dengan: |
| 419 | 419 | ||
| 420 | ```yuescript | 420 | ```yuescript |
| 421 | findFirstEven = (list) -> | 421 | findFirstEven = (list) -> |
| @@ -440,11 +440,11 @@ findFirstEven = (list) -> | |||
| 440 | 440 | ||
| 441 | </YueDisplay> | 441 | </YueDisplay> |
| 442 | 442 | ||
| 443 | The only difference is that you can move the final return expression before the `->` or `=>` token to indicate the function’s implicit return value as the last statement. This way, even in functions with multiple nested loops or conditional branches, you no longer need to write a trailing return expression at the end of the function body, making the logic structure more straightforward and easier to follow. | 443 | Satu-satunya perbedaan adalah Anda dapat memindahkan ekspresi return terakhir sebelum token `->` atau `=>` untuk menunjukkan nilai return implisit fungsi sebagai pernyataan terakhir. Dengan cara ini, bahkan pada fungsi dengan banyak loop bertingkat atau cabang kondisional, Anda tidak lagi perlu menulis ekspresi return di akhir badan fungsi, sehingga struktur logika menjadi lebih lurus dan mudah diikuti. |
| 444 | 444 | ||
| 445 | ## Named Varargs | 445 | ## Varargs Bernama |
| 446 | 446 | ||
| 447 | You can use the `(...t) ->` syntax to automatically store varargs into a named table. This table will contain all passed arguments (including `nil` values), and the `n` field of the table will store the actual number of arguments passed (including `nil` values). | 447 | Anda dapat menggunakan sintaks `(...t) ->` untuk otomatis menyimpan varargs ke tabel bernama. Tabel ini berisi semua argumen yang diteruskan (termasuk nilai `nil`), dan field `n` pada tabel menyimpan jumlah argumen yang benar-benar diteruskan (termasuk nilai `nil`). |
| 448 | 448 | ||
| 449 | ```yuescript | 449 | ```yuescript |
| 450 | f = (...t) -> | 450 | f = (...t) -> |
| @@ -457,7 +457,7 @@ f 1, 2, 3 | |||
| 457 | f "a", "b", "c", "d" | 457 | f "a", "b", "c", "d" |
| 458 | f! | 458 | f! |
| 459 | 459 | ||
| 460 | -- Handling cases with nil values | 460 | -- Menangani kasus dengan nilai nil |
| 461 | process = (...args) -> | 461 | process = (...args) -> |
| 462 | sum = 0 | 462 | sum = 0 |
| 463 | for i = 1, args.n | 463 | for i = 1, args.n |
| @@ -480,7 +480,7 @@ f 1, 2, 3 | |||
| 480 | f "a", "b", "c", "d" | 480 | f "a", "b", "c", "d" |
| 481 | f! | 481 | f! |
| 482 | 482 | ||
| 483 | -- Handling cases with nil values | 483 | -- Menangani kasus dengan nilai nil |
| 484 | process = (...args) -> | 484 | process = (...args) -> |
| 485 | sum = 0 | 485 | sum = 0 |
| 486 | for i = 1, args.n | 486 | for i = 1, args.n |
diff --git a/doc/docs/id-id/doc/functions/function-stubs.md b/doc/docs/id-id/doc/functions/function-stubs.md index 57a8b0c..57ed5c1 100644 --- a/doc/docs/id-id/doc/functions/function-stubs.md +++ b/doc/docs/id-id/doc/functions/function-stubs.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Function Stubs | 1 | # Stub Fungsi |
| 2 | 2 | ||
| 3 | It is common to pass a function from an object around as a value, for example, passing an instance method into a function as a callback. If the function expects the object it is operating on as the first argument then you must somehow bundle that object with the function so it can be called properly. | 3 | Sering kali fungsi dari sebuah objek diteruskan sebagai nilai, misalnya meneruskan method instance ke fungsi lain sebagai callback. Jika fungsi mengharapkan objek yang dioperasikan sebagai argumen pertama, maka Anda harus menggabungkan objek tersebut dengan fungsi agar dapat dipanggil dengan benar. |
| 4 | 4 | ||
| 5 | The function stub syntax is a shorthand for creating a new closure function that bundles both the object and function. This new function calls the wrapped function in the correct context of the object. | 5 | Sintaks stub fungsi adalah singkatan untuk membuat fungsi closure baru yang menggabungkan objek dan fungsi. Fungsi baru ini memanggil fungsi yang dibungkus dalam konteks objek yang benar. |
| 6 | 6 | ||
| 7 | Its syntax is the same as calling an instance method with the \ operator but with no argument list provided. | 7 | Sintaksnya sama seperti memanggil method instance dengan operator `\`, tetapi tanpa menyediakan daftar argumen. |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | my_object = { | 10 | my_object = { |
| @@ -16,12 +16,12 @@ run_callback = (func) -> | |||
| 16 | print "running callback..." | 16 | print "running callback..." |
| 17 | func! | 17 | func! |
| 18 | 18 | ||
| 19 | -- this will not work: | 19 | -- ini tidak akan berfungsi: |
| 20 | -- the function has to no reference to my_object | 20 | -- fungsi tidak memiliki referensi ke my_object |
| 21 | run_callback my_object.write | 21 | run_callback my_object.write |
| 22 | 22 | ||
| 23 | -- function stub syntax | 23 | -- sintaks stub fungsi |
| 24 | -- lets us bundle the object into a new function | 24 | -- memungkinkan kita membundel objek ke fungsi baru |
| 25 | run_callback my_object\write | 25 | run_callback my_object\write |
| 26 | ``` | 26 | ``` |
| 27 | <YueDisplay> | 27 | <YueDisplay> |
| @@ -36,12 +36,12 @@ run_callback = (func) -> | |||
| 36 | print "running callback..." | 36 | print "running callback..." |
| 37 | func! | 37 | func! |
| 38 | 38 | ||
| 39 | -- this will not work: | 39 | -- ini tidak akan berfungsi: |
| 40 | -- the function has to no reference to my_object | 40 | -- fungsi tidak memiliki referensi ke my_object |
| 41 | run_callback my_object.write | 41 | run_callback my_object.write |
| 42 | 42 | ||
| 43 | -- function stub syntax | 43 | -- sintaks stub fungsi |
| 44 | -- lets us bundle the object into a new function | 44 | -- memungkinkan kita membundel objek ke fungsi baru |
| 45 | run_callback my_object\write | 45 | run_callback my_object\write |
| 46 | ``` | 46 | ``` |
| 47 | 47 | ||
diff --git a/doc/docs/id-id/doc/getting-started/installation.md b/doc/docs/id-id/doc/getting-started/installation.md index a93ddfd..2809cca 100644 --- a/doc/docs/id-id/doc/getting-started/installation.md +++ b/doc/docs/id-id/doc/getting-started/installation.md | |||
| @@ -1,43 +1,43 @@ | |||
| 1 | # Installation | 1 | # Instalasi |
| 2 | 2 | ||
| 3 | ## Lua Module | 3 | ## Modul Lua |
| 4 | 4 | ||
| 5 | Install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module and executable with: | 5 | Instal [luarocks](https://luarocks.org), manajer paket untuk modul Lua. Lalu instal sebagai modul Lua dan executable dengan: |
| 6 | 6 | ||
| 7 | ```shell | 7 | ```shell |
| 8 | luarocks install yuescript | 8 | luarocks install yuescript |
| 9 | ``` | 9 | ``` |
| 10 | 10 | ||
| 11 | Or you can build `yue.so` file with: | 11 | Atau Anda dapat membangun file `yue.so` dengan: |
| 12 | 12 | ||
| 13 | ```shell | 13 | ```shell |
| 14 | make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua | 14 | make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua |
| 15 | ``` | 15 | ``` |
| 16 | 16 | ||
| 17 | Then get the binary file from path **bin/shared/yue.so**. | 17 | Lalu ambil file biner dari path **bin/shared/yue.so**. |
| 18 | 18 | ||
| 19 | ## Build Binary Tool | 19 | ## Membangun Tool Biner |
| 20 | 20 | ||
| 21 | Clone this repo, then build and install executable with: | 21 | Klon repo ini, lalu bangun dan instal executable dengan: |
| 22 | 22 | ||
| 23 | ```shell | 23 | ```shell |
| 24 | make install | 24 | make install |
| 25 | ``` | 25 | ``` |
| 26 | 26 | ||
| 27 | Build YueScript tool without macro feature: | 27 | Bangun tool YueScript tanpa fitur macro: |
| 28 | 28 | ||
| 29 | ```shell | 29 | ```shell |
| 30 | make install NO_MACRO=true | 30 | make install NO_MACRO=true |
| 31 | ``` | 31 | ``` |
| 32 | 32 | ||
| 33 | Build YueScript tool without built-in Lua binary: | 33 | Bangun tool YueScript tanpa biner Lua bawaan: |
| 34 | 34 | ||
| 35 | ```shell | 35 | ```shell |
| 36 | make install NO_LUA=true | 36 | make install NO_LUA=true |
| 37 | ``` | 37 | ``` |
| 38 | 38 | ||
| 39 | ## Download Precompiled Binary | 39 | ## Unduh Biner Pra-kompilasi |
| 40 | 40 | ||
| 41 | You can download precompiled binary files, including binary executable files compatible with different Lua versions and library files. | 41 | Anda dapat mengunduh file biner pra-kompilasi, termasuk file executable biner yang kompatibel dengan berbagai versi Lua dan file library. |
| 42 | 42 | ||
| 43 | Download precompiled binary files from [here](https://github.com/IppClub/YueScript/releases). | 43 | Unduh file biner pra-kompilasi dari [sini](https://github.com/IppClub/YueScript/releases). |
diff --git a/doc/docs/id-id/doc/getting-started/introduction.md b/doc/docs/id-id/doc/getting-started/introduction.md index a9a9389..c2fc236 100644 --- a/doc/docs/id-id/doc/getting-started/introduction.md +++ b/doc/docs/id-id/doc/getting-started/introduction.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Introduction | 1 | # Pendahuluan |
| 2 | 2 | ||
| 3 | YueScript is a dynamic language that compiles to Lua. And it's a [MoonScript](https://github.com/leafo/moonscript) dialect. The codes written in YueScript are expressive and extremely concise. And it is suitable for writing some changing application logic with more maintainable codes and runs in a Lua embeded environment such as games or website servers. | 3 | YueScript adalah bahasa dinamis yang dikompilasi ke Lua, dan merupakan dialek [MoonScript](https://github.com/leafo/moonscript). Kode yang ditulis dengan YueScript ekspresif dan sangat ringkas. YueScript cocok untuk menulis logika aplikasi yang sering berubah dengan kode yang lebih mudah dipelihara, serta berjalan di lingkungan embed Lua seperti game atau server situs web. |
| 4 | 4 | ||
| 5 | Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ]. | 5 | Yue (月) adalah kata untuk bulan dalam bahasa Tionghoa dan diucapkan sebagai [jyɛ]. |
| 6 | 6 | ||
| 7 | ## An Overview of YueScript | 7 | ## Ikhtisar YueScript |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | -- import syntax | 10 | -- import syntax |
| @@ -48,7 +48,7 @@ with apple | |||
| 48 | p .size, .color, .<index> if .<>? | 48 | p .size, .color, .<index> if .<>? |
| 49 | 49 | ||
| 50 | -- js-like export syntax | 50 | -- js-like export syntax |
| 51 | export 🌛 = "月之脚本" | 51 | export 🌛 = "Skrip Bulan" |
| 52 | ``` | 52 | ``` |
| 53 | 53 | ||
| 54 | <YueDisplay> | 54 | <YueDisplay> |
| @@ -95,11 +95,11 @@ with apple | |||
| 95 | p .size, .color, .<index> if .<>? | 95 | p .size, .color, .<index> if .<>? |
| 96 | 96 | ||
| 97 | -- js-like export syntax | 97 | -- js-like export syntax |
| 98 | export 🌛 = "月之脚本" | 98 | export 🌛 = "Skrip Bulan" |
| 99 | ``` | 99 | ``` |
| 100 | 100 | ||
| 101 | </YueDisplay> | 101 | </YueDisplay> |
| 102 | 102 | ||
| 103 | ## About Dora SSR | 103 | ## Tentang Dora SSR |
| 104 | 104 | ||
| 105 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/Dora-SSR/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. \ No newline at end of file | 105 | YueScript dikembangkan dan dipelihara bersama mesin game open-source [Dora SSR](https://github.com/Dora-SSR/Dora-SSR). YueScript telah digunakan untuk membuat alat mesin, demo game, dan prototipe, membuktikan kemampuannya dalam skenario dunia nyata sekaligus meningkatkan pengalaman pengembangan Dora SSR. |
diff --git a/doc/docs/id-id/doc/getting-started/usage.md b/doc/docs/id-id/doc/getting-started/usage.md index 45161c6..85cad07 100644 --- a/doc/docs/id-id/doc/getting-started/usage.md +++ b/doc/docs/id-id/doc/getting-started/usage.md | |||
| @@ -1,20 +1,20 @@ | |||
| 1 | # Usage | 1 | # Penggunaan |
| 2 | 2 | ||
| 3 | ## Lua Module | 3 | ## Modul Lua |
| 4 | 4 | ||
| 5 | Use YueScript module in Lua: | 5 | Gunakan modul YueScript di Lua: |
| 6 | 6 | ||
| 7 | * **Case 1** | 7 | * **Kasus 1** |
| 8 | 8 | ||
| 9 | Require "your_yuescript_entry.yue" in Lua. | 9 | Require "your_yuescript_entry.yue" di Lua. |
| 10 | ```Lua | 10 | ```Lua |
| 11 | require("yue")("your_yuescript_entry") | 11 | require("yue")("your_yuescript_entry") |
| 12 | ``` | 12 | ``` |
| 13 | And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest YueScript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly. | 13 | Dan kode ini tetap bekerja ketika Anda mengompilasi "your_yuescript_entry.yue" menjadi "your_yuescript_entry.lua" di path yang sama. Pada file YueScript lainnya cukup gunakan **require** atau **import** biasa. Nomor baris pada pesan error juga akan ditangani dengan benar. |
| 14 | 14 | ||
| 15 | * **Case 2** | 15 | * **Kasus 2** |
| 16 | 16 | ||
| 17 | Require YueScript module and rewite message by hand. | 17 | Require modul YueScript dan tulis ulang pesan secara manual. |
| 18 | 18 | ||
| 19 | ```lua | 19 | ```lua |
| 20 | local yue = require("yue") | 20 | local yue = require("yue") |
| @@ -26,9 +26,9 @@ Use YueScript module in Lua: | |||
| 26 | end) | 26 | end) |
| 27 | ``` | 27 | ``` |
| 28 | 28 | ||
| 29 | * **Case 3** | 29 | * **Kasus 3** |
| 30 | 30 | ||
| 31 | Use the YueScript compiler function in Lua. | 31 | Gunakan fungsi kompiler YueScript di Lua. |
| 32 | 32 | ||
| 33 | ```lua | 33 | ```lua |
| 34 | local yue = require("yue") | 34 | local yue = require("yue") |
| @@ -48,64 +48,65 @@ Use YueScript module in Lua: | |||
| 48 | }) | 48 | }) |
| 49 | ``` | 49 | ``` |
| 50 | 50 | ||
| 51 | ## YueScript Tool | 51 | ## Tool YueScript |
| 52 | 52 | ||
| 53 | Use YueScript tool with: | 53 | Gunakan tool YueScript dengan: |
| 54 | 54 | ||
| 55 | ```shell | 55 | ```shell |
| 56 | > yue -h | 56 | > yue -h |
| 57 | Usage: yue | 57 | Penggunaan: yue |
| 58 | [options] [<file/directory>] ... | 58 | [opsi] [<file/direktori>] ... |
| 59 | yue -e <code_or_file> [args...] | 59 | yue -e <kode_atau_file> [argumen...] |
| 60 | yue -w [<directory>] [options] | 60 | yue -w [<direktori>] [opsi] |
| 61 | yue - | 61 | yue - |
| 62 | 62 | ||
| 63 | Notes: | 63 | Catatan: |
| 64 | - '-' / '--' must be the first and only argument. | 64 | - '-' / '--' harus menjadi argumen pertama dan satu-satunya. |
| 65 | - '-o/--output' can not be used with multiple input files. | 65 | - '-o/--output' tidak dapat digunakan dengan beberapa file input. |
| 66 | - '-w/--watch' can not be used with file input (directory only). | 66 | - '-w/--watch' tidak dapat digunakan dengan file input (khusus direktori). |
| 67 | - with '-e/--execute', remaining tokens are treated as script args. | 67 | - dengan '-e/--execute', token sisanya dianggap sebagai argumen skrip. |
| 68 | 68 | ||
| 69 | Options: | 69 | Opsi: |
| 70 | -h, --help Show this help message and exit. | 70 | -h, --help Tampilkan pesan bantuan ini dan keluar. |
| 71 | -e <str>, --execute <str> Execute a file or raw codes | 71 | -e <str>, --execute <str> Eksekusi file atau kode mentah |
| 72 | -m, --minify Generate minified codes | 72 | -m, --minify Menghasilkan kode yang sudah diminimasi |
| 73 | -r, --rewrite Rewrite output to match original line numbers | 73 | -r, --rewrite Tulis ulang output agar sesuai dengan nomor baris asal |
| 74 | -t <output_to>, --output-to <output_to> | 74 | -t <output_to>, --output-to <output_to> |
| 75 | Specify where to place compiled files | 75 | Tentukan lokasi untuk menaruh file hasil kompilasi |
| 76 | -o <file>, --output <file> Write output to file | 76 | -o <file>, --output <file> Tulis output ke file |
| 77 | -p, --print Write output to standard out | 77 | -p, --print Tulis output ke standar output |
| 78 | -b, --benchmark Dump compile time (doesn't write output) | 78 | -b, --benchmark Tampilkan waktu kompilasi (tanpa menulis output) |
| 79 | -g, --globals Dump global variables used in NAME LINE COLUMN | 79 | -g, --globals Tampilkan variabel global yang digunakan dalam FORMAT NAMA BARIS KOLOM |
| 80 | -s, --spaces Use spaces in generated codes instead of tabs | 80 | -s, --spaces Pakai spasi di kode hasil kompilasi (bukan tab) |
| 81 | -l, --line-numbers Write line numbers from source codes | 81 | -l, --line-numbers Tulis nomor baris dari kode sumber |
| 82 | -j, --no-implicit-return Disable implicit return at end of file | 82 | -j, --no-implicit-return Nonaktifkan return implisit di akhir file |
| 83 | -c, --reserve-comments Reserve comments before statement from source codes | 83 | -c, --reserve-comments Pertahankan komentar sebelum pernyataan dari kode sumber |
| 84 | -w [<dir>], --watch [<dir>] | 84 | -w [<dir>], --watch [<dir>] |
| 85 | Watch changes and compile every file under directory | 85 | Pantau perubahan dan kompilasi setiap file di bawah direktori |
| 86 | -v, --version Print version | 86 | -v, --version Tampilkan versi |
| 87 | - Read from standard in, print to standard out | 87 | - Baca dari standar input, tulis ke standar output |
| 88 | (Must be first and only argument) | 88 | (harus menjadi argumen pertama dan satu-satunya) |
| 89 | -- Same as '-' (kept for backward compatibility) | 89 | -- Sama dengan '-', dipertahankan untuk kompatibilitas lama |
| 90 | 90 | ||
| 91 | --target <version> Specify the Lua version that codes will be generated to | 91 | --target <versi> Tentukan versi Lua yang akan dihasilkan kodenya |
| 92 | (version can only be 5.1 to 5.5) | 92 | (versi hanya bisa dari 5.1 sampai 5.5) |
| 93 | --path <path_str> Append an extra Lua search path string to package.path | 93 | --path <path_str> Tambahkan path pencarian Lua tambahan ke package.path |
| 94 | --<key>=<value> Pass compiler option in key=value form (existing behavior) | 94 | --<key>=<value> Kirim opsi kompilasi dalam bentuk key=value (perilaku standar) |
| 95 | 95 | ||
| 96 | Execute without options to enter REPL, type symbol '$' | 96 | Jalankan tanpa opsi untuk masuk ke REPL, ketik simbol '$' |
| 97 | in a single line to start/stop multi-line mode | 97 | dalam satu baris untuk memulai/mengakhiri mode multi-baris |
| 98 | ``` | 98 | ``` |
| 99 | Use cases: | ||
| 100 | 99 | ||
| 101 | Recursively compile every YueScript file with extension **.yue** under current path: **yue .** | 100 | Gunakan kasus: |
| 102 | 101 | ||
| 103 | Compile and save results to a target path: **yue -t /target/path/ .** | 102 | Kompilasi semua file YueScript dengan ekstensi **.yue** secara rekursif di bawah path saat ini: **yue .** |
| 104 | 103 | ||
| 105 | Compile and reserve debug info: **yue -l .** | 104 | Kompilasi dan simpan hasil ke path target: **yue -t /target/path/ .** |
| 106 | 105 | ||
| 107 | Compile and generate minified codes: **yue -m .** | 106 | Kompilasi dan pertahankan info debug: **yue -l .** |
| 108 | 107 | ||
| 109 | Execute raw codes: **yue -e 'print 123'** | 108 | Kompilasi dan hasilkan kode yang diminisasi: **yue -m .** |
| 110 | 109 | ||
| 111 | Execute a YueScript file: **yue -e main.yue** | 110 | Eksekusi kode mentah: **yue -e 'print 123'** |
| 111 | |||
| 112 | Eksekusi file YueScript: **yue -e main.yue** | ||
diff --git a/doc/docs/id-id/doc/index.md b/doc/docs/id-id/doc/index.md index b7f609b..5df2cc3 100755 --- a/doc/docs/id-id/doc/index.md +++ b/doc/docs/id-id/doc/index.md | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | --- | 1 | --- |
| 2 | title: Reference | 2 | title: Referensi |
| 3 | --- | 3 | --- |
| 4 | 4 | ||
| 5 | # YueScript Documentation | 5 | # Dokumentasi YueScript |
| 6 | 6 | ||
| 7 | <img src="/image/yuescript.svg" width="250px" height="250px" alt="logo" style="padding-top: 3em; padding-bottom: 2em;"/> | 7 | <img src="/image/yuescript.svg" width="250px" height="250px" alt="logo" style="padding-top: 3em; padding-bottom: 2em;"/> |
| 8 | 8 | ||
| 9 | Welcome to the <b>YueScript</b> official documentation!<br/> | 9 | Selamat datang di dokumentasi resmi <b>YueScript</b>!<br/> |
| 10 | Here you can find the language features, usage, reference examples and resources.<br/> | 10 | Di sini Anda dapat menemukan fitur bahasa, penggunaan, contoh referensi, dan sumber daya.<br/> |
| 11 | Please select a chapter from the sidebar to start learning about YueScript. | 11 | Silakan pilih bab dari sidebar untuk mulai mempelajari YueScript. |
diff --git a/doc/docs/id-id/doc/language-basics/attributes.md b/doc/docs/id-id/doc/language-basics/attributes.md index e6fd5a7..5b92947 100644 --- a/doc/docs/id-id/doc/language-basics/attributes.md +++ b/doc/docs/id-id/doc/language-basics/attributes.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Attributes | 1 | # Atribut |
| 2 | 2 | ||
| 3 | Syntax support for Lua 5.4 attributes. And you can still use both the `const` and `close` declaration and get constant check and scoped callback working when targeting Lua versions below 5.4. | 3 | Dukungan sintaks untuk atribut Lua 5.4. Anda juga masih bisa menggunakan deklarasi `const` dan `close` dan mendapatkan pemeriksaan konstanta serta callback berbatas-scope ketika menargetkan versi Lua di bawah 5.4. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | const a = 123 | 6 | const a = 123 |
| @@ -15,7 +15,7 @@ close _ = <close>: -> print "Out of scope." | |||
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | You can do desctructuring with variables attributed as constant. | 18 | Anda dapat melakukan destrukturisasi dengan variabel yang diberi atribut sebagai konstanta. |
| 19 | 19 | ||
| 20 | ```yuescript | 20 | ```yuescript |
| 21 | const {:a, :b, c, d} = tb | 21 | const {:a, :b, c, d} = tb |
| @@ -30,7 +30,7 @@ const {:a, :b, c, d} = tb | |||
| 30 | 30 | ||
| 31 | </YueDisplay> | 31 | </YueDisplay> |
| 32 | 32 | ||
| 33 | You can also declare a global variable to be `const`. | 33 | Anda juga bisa mendeklarasikan variabel global sebagai `const`. |
| 34 | 34 | ||
| 35 | ```yuescript | 35 | ```yuescript |
| 36 | global const Constant = 123 | 36 | global const Constant = 123 |
diff --git a/doc/docs/id-id/doc/language-basics/comment.md b/doc/docs/id-id/doc/language-basics/comment.md index b67c97d..99f7b51 100644 --- a/doc/docs/id-id/doc/language-basics/comment.md +++ b/doc/docs/id-id/doc/language-basics/comment.md | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | # Comment | 1 | # Komentar |
| 2 | 2 | ||
| 3 | ```yuescript | 3 | ```yuescript |
| 4 | -- I am a comment | 4 | -- Saya adalah komentar |
| 5 | 5 | ||
| 6 | str = --[[ | 6 | str = --[[ |
| 7 | This is a multi-line comment. | 7 | Ini komentar multi-baris. |
| 8 | It's OK. | 8 | Tidak masalah. |
| 9 | ]] strA \ -- comment 1 | 9 | ]] strA \ -- komentar 1 |
| 10 | .. strB \ -- comment 2 | 10 | .. strB \ -- komentar 2 |
| 11 | .. strC | 11 | .. strC |
| 12 | 12 | ||
| 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 13 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
| @@ -15,13 +15,13 @@ func --[[port]] 3000, --[[ip]] "192.168.1.1" | |||
| 15 | <YueDisplay> | 15 | <YueDisplay> |
| 16 | 16 | ||
| 17 | ```yue | 17 | ```yue |
| 18 | -- I am a comment | 18 | -- Saya adalah komentar |
| 19 | 19 | ||
| 20 | str = --[[ | 20 | str = --[[ |
| 21 | This is a multi-line comment. | 21 | Ini komentar multi-baris. |
| 22 | It's OK. | 22 | Tidak masalah. |
| 23 | ]] strA \ -- comment 1 | 23 | ]] strA \ -- komentar 1 |
| 24 | .. strB \ -- comment 2 | 24 | .. strB \ -- komentar 2 |
| 25 | .. strC | 25 | .. strC |
| 26 | 26 | ||
| 27 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 27 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
diff --git a/doc/docs/id-id/doc/language-basics/literals.md b/doc/docs/id-id/doc/language-basics/literals.md index e097c62..c17c310 100644 --- a/doc/docs/id-id/doc/language-basics/literals.md +++ b/doc/docs/id-id/doc/language-basics/literals.md | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | # Literals | 1 | # Literal |
| 2 | 2 | ||
| 3 | All of the primitive literals in Lua can be used. This applies to numbers, strings, booleans, and **nil**. | 3 | Semua literal primitif di Lua dapat digunakan. Ini berlaku untuk angka, string, boolean, dan **nil**. |
| 4 | 4 | ||
| 5 | Unlike Lua, Line breaks are allowed inside of single and double quote strings without an escape sequence: | 5 | Berbeda dengan Lua, pemisah baris diizinkan di dalam string bertanda kutip tunggal maupun ganda tanpa urutan escape: |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | some_string = "Here is a string | 8 | some_string = "Here is a string |
| 9 | that has a line break in it." | 9 | that has a line break in it." |
| 10 | 10 | ||
| 11 | -- You can mix expressions into string literals using #{} syntax. | 11 | -- Anda dapat mencampur ekspresi ke dalam literal string dengan sintaks #{}. |
| 12 | -- String interpolation is only available in double quoted strings. | 12 | -- Interpolasi string hanya tersedia pada string dengan tanda kutip ganda. |
| 13 | print "I am #{math.random! * 100}% sure." | 13 | print "I am #{math.random! * 100}% sure." |
| 14 | ``` | 14 | ``` |
| 15 | <YueDisplay> | 15 | <YueDisplay> |
| @@ -18,16 +18,16 @@ print "I am #{math.random! * 100}% sure." | |||
| 18 | some_string = "Here is a string | 18 | some_string = "Here is a string |
| 19 | that has a line break in it." | 19 | that has a line break in it." |
| 20 | 20 | ||
| 21 | -- You can mix expressions into string literals using #{} syntax. | 21 | -- Anda dapat mencampur ekspresi ke dalam literal string dengan sintaks #{}. |
| 22 | -- String interpolation is only available in double quoted strings. | 22 | -- Interpolasi string hanya tersedia pada string dengan tanda kutip ganda. |
| 23 | print "I am #{math.random! * 100}% sure." | 23 | print "I am #{math.random! * 100}% sure." |
| 24 | ``` | 24 | ``` |
| 25 | 25 | ||
| 26 | </YueDisplay> | 26 | </YueDisplay> |
| 27 | 27 | ||
| 28 | ## Number Literals | 28 | ## Literal Angka |
| 29 | 29 | ||
| 30 | You can use underscores in a number literal to increase readability. | 30 | Anda bisa menggunakan garis bawah pada literal angka untuk meningkatkan keterbacaan. |
| 31 | 31 | ||
| 32 | ```yuescript | 32 | ```yuescript |
| 33 | integer = 1_000_000 | 33 | integer = 1_000_000 |
| @@ -44,9 +44,9 @@ binary = 0B10011 | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | ## YAML Multiline String | 47 | ## String Multibaris YAML |
| 48 | 48 | ||
| 49 | The `|` prefix introduces a YAML-style multiline string literal: | 49 | Prefiks `|` memperkenalkan literal string multibaris bergaya YAML: |
| 50 | 50 | ||
| 51 | ```yuescript | 51 | ```yuescript |
| 52 | str = | | 52 | str = | |
| @@ -67,9 +67,9 @@ str = | | |||
| 67 | 67 | ||
| 68 | </YueDisplay> | 68 | </YueDisplay> |
| 69 | 69 | ||
| 70 | This allows writing structured multiline text conveniently. All line breaks and indentation are preserved relative to the first non-empty line, and expressions inside `#{...}` are interpolated automatically as `tostring(expr)`. | 70 | Ini memungkinkan penulisan teks multibaris terstruktur dengan mudah. Semua pemisah baris dan indentasi dipertahankan relatif terhadap baris non-kosong pertama, dan ekspresi di dalam `#{...}` diinterpolasi otomatis sebagai `tostring(expr)`. |
| 71 | 71 | ||
| 72 | YAML Multiline String automatically detects the common leading whitespace prefix (minimum indentation across all non-empty lines) and removes it from all lines. This makes it easy to indent your code visually without affecting the resulting string content. | 72 | String Multibaris YAML secara otomatis mendeteksi prefiks spasi awal yang sama (indentasi minimum di seluruh baris non-kosong) dan menghapusnya dari semua baris. Ini memudahkan untuk mengindentasi kode secara visual tanpa memengaruhi isi string yang dihasilkan. |
| 73 | 73 | ||
| 74 | ```yuescript | 74 | ```yuescript |
| 75 | fn = -> | 75 | fn = -> |
| @@ -90,9 +90,9 @@ fn = -> | |||
| 90 | 90 | ||
| 91 | </YueDisplay> | 91 | </YueDisplay> |
| 92 | 92 | ||
| 93 | Internal indentation is preserved relative to the removed common prefix, allowing clean nested structures. | 93 | Indentasi internal dipertahankan relatif terhadap prefiks umum yang dihapus, sehingga struktur bertingkat tetap rapi. |
| 94 | 94 | ||
| 95 | All special characters like quotes (`"`) and backslashes (`\`) in the YAMLMultiline block are automatically escaped so that the generated Lua string is syntactically valid and behaves as expected. | 95 | Semua karakter khusus seperti tanda kutip (`"`) dan backslash (`\`) di dalam blok YAMLMultiline di-escape secara otomatis agar string Lua yang dihasilkan valid secara sintaks dan berperilaku sebagaimana mestinya. |
| 96 | 96 | ||
| 97 | ```yuescript | 97 | ```yuescript |
| 98 | str = | | 98 | str = | |
diff --git a/doc/docs/id-id/doc/language-basics/operator.md b/doc/docs/id-id/doc/language-basics/operator.md index 9a2e89b..f3fe092 100644 --- a/doc/docs/id-id/doc/language-basics/operator.md +++ b/doc/docs/id-id/doc/language-basics/operator.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Operator | 1 | # Operator |
| 2 | 2 | ||
| 3 | All of Lua's binary and unary operators are available. Additionally **!=** is as an alias for **~=**, and either **\\** or **::** can be used to write a chaining function call like `tb\func!` or `tb::func!`. And Yuescipt offers some other special operators to write more expressive codes. | 3 | Semua operator biner dan unari Lua tersedia. Selain itu **!=** adalah alias untuk **~=**, dan **\\** atau **::** bisa digunakan untuk menulis pemanggilan fungsi berantai seperti `tb\func!` atau `tb::func!`. YueScript juga menawarkan beberapa operator khusus lain untuk menulis kode yang lebih ekspresif. |
| 4 | 4 | ||
| 5 | ```yuescript | 5 | ```yuescript |
| 6 | tb\func! if tb ~= nil | 6 | tb\func! if tb ~= nil |
| @@ -15,9 +15,9 @@ tb::func! if tb != nil | |||
| 15 | 15 | ||
| 16 | </YueDisplay> | 16 | </YueDisplay> |
| 17 | 17 | ||
| 18 | ## Chaining Comparisons | 18 | ## Perbandingan Berantai |
| 19 | 19 | ||
| 20 | Comparisons can be arbitrarily chained: | 20 | Perbandingan bisa dirantai secara bebas: |
| 21 | 21 | ||
| 22 | ```yuescript | 22 | ```yuescript |
| 23 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 | 23 | print 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 != 5 |
| @@ -40,7 +40,7 @@ print 1 <= a <= 10 | |||
| 40 | 40 | ||
| 41 | </YueDisplay> | 41 | </YueDisplay> |
| 42 | 42 | ||
| 43 | Note the evaluation behavior of chained comparisons: | 43 | Perhatikan perilaku evaluasi perbandingan berantai: |
| 44 | 44 | ||
| 45 | ```yuescript | 45 | ```yuescript |
| 46 | v = (x) -> | 46 | v = (x) -> |
| @@ -91,11 +91,11 @@ print v(1) > v(2) <= v(3) | |||
| 91 | 91 | ||
| 92 | </YueDisplay> | 92 | </YueDisplay> |
| 93 | 93 | ||
| 94 | The middle expression is only evaluated once, rather than twice as it would be if the expression were written as `v(1) < v(2) and v(2) <= v(3)`. However, the order of evaluations in a chained comparison is undefined. It is strongly recommended not to use expressions with side effects (such as printing) in chained comparisons. If side effects are required, the short-circuit `and` operator should be used explicitly. | 94 | Ekspresi tengah hanya dievaluasi sekali, bukan dua kali seperti jika ekspresi ditulis sebagai `v(1) < v(2) and v(2) <= v(3)`. Namun, urutan evaluasi pada perbandingan berantai tidak didefinisikan. Sangat disarankan untuk tidak menggunakan ekspresi dengan efek samping (seperti `print`) di perbandingan berantai. Jika efek samping diperlukan, operator short-circuit `and` sebaiknya digunakan secara eksplisit. |
| 95 | 95 | ||
| 96 | ## Table Appending | 96 | ## Menambahkan ke Tabel |
| 97 | 97 | ||
| 98 | The **[] =** operator is used to append values to tables. | 98 | Operator **[] =** digunakan untuk menambahkan nilai ke tabel. |
| 99 | 99 | ||
| 100 | ```yuescript | 100 | ```yuescript |
| 101 | tab = [] | 101 | tab = [] |
| @@ -110,13 +110,13 @@ tab[] = "Value" | |||
| 110 | 110 | ||
| 111 | </YueDisplay> | 111 | </YueDisplay> |
| 112 | 112 | ||
| 113 | You can also use the spread operator `...` to append all elements from one list to another: | 113 | Anda juga bisa memakai operator spread `...` untuk menambahkan semua elemen dari satu list ke list lain: |
| 114 | 114 | ||
| 115 | ```yuescript | 115 | ```yuescript |
| 116 | tbA = [1, 2, 3] | 116 | tbA = [1, 2, 3] |
| 117 | tbB = [4, 5, 6] | 117 | tbB = [4, 5, 6] |
| 118 | tbA[] = ...tbB | 118 | tbA[] = ...tbB |
| 119 | -- tbA is now [1, 2, 3, 4, 5, 6] | 119 | -- tbA sekarang [1, 2, 3, 4, 5, 6] |
| 120 | ``` | 120 | ``` |
| 121 | <YueDisplay> | 121 | <YueDisplay> |
| 122 | 122 | ||
| @@ -124,14 +124,14 @@ tbA[] = ...tbB | |||
| 124 | tbA = [1, 2, 3] | 124 | tbA = [1, 2, 3] |
| 125 | tbB = [4, 5, 6] | 125 | tbB = [4, 5, 6] |
| 126 | tbA[] = ...tbB | 126 | tbA[] = ...tbB |
| 127 | -- tbA is now [1, 2, 3, 4, 5, 6] | 127 | -- tbA sekarang [1, 2, 3, 4, 5, 6] |
| 128 | ``` | 128 | ``` |
| 129 | 129 | ||
| 130 | </YueDisplay> | 130 | </YueDisplay> |
| 131 | 131 | ||
| 132 | ## Table Spreading | 132 | ## Penyebaran Tabel |
| 133 | 133 | ||
| 134 | You can concatenate array tables or hash tables using spread operator `...` before expressions in table literals. | 134 | Anda bisa menggabungkan tabel array atau tabel hash menggunakan operator spread `...` sebelum ekspresi di literal tabel. |
| 135 | 135 | ||
| 136 | ```yuescript | 136 | ```yuescript |
| 137 | parts = | 137 | parts = |
| @@ -170,9 +170,9 @@ merge = {...a, ...b} | |||
| 170 | 170 | ||
| 171 | </YueDisplay> | 171 | </YueDisplay> |
| 172 | 172 | ||
| 173 | ## Table Reversed Indexing | 173 | ## Indeks Balik Tabel |
| 174 | 174 | ||
| 175 | You can use the **#** operator to get the last elements of a table. | 175 | Anda dapat menggunakan operator **#** untuk mendapatkan elemen terakhir dari tabel. |
| 176 | 176 | ||
| 177 | ```yuescript | 177 | ```yuescript |
| 178 | last = data.items[#] | 178 | last = data.items[#] |
| @@ -191,11 +191,11 @@ data.items[#] = 1 | |||
| 191 | 191 | ||
| 192 | ## Metatable | 192 | ## Metatable |
| 193 | 193 | ||
| 194 | The **<>** operator can be used as a shortcut for metatable manipulation. | 194 | Operator **<>** dapat digunakan sebagai pintasan untuk manipulasi metatable. |
| 195 | 195 | ||
| 196 | ### Metatable Creation | 196 | ### Pembuatan Metatable |
| 197 | 197 | ||
| 198 | Create normal table with empty bracekets **<>** or metamethod key which is surrounded by **<>**. | 198 | Buat tabel normal dengan tanda kurung siku kosong **<>** atau kunci metamethod yang dikelilingi oleh **<>**. |
| 199 | 199 | ||
| 200 | ```yuescript | 200 | ```yuescript |
| 201 | mt = {} | 201 | mt = {} |
| @@ -203,7 +203,7 @@ add = (right) => <>: mt, value: @value + right.value | |||
| 203 | mt.__add = add | 203 | mt.__add = add |
| 204 | 204 | ||
| 205 | a = <>: mt, value: 1 | 205 | a = <>: mt, value: 1 |
| 206 | -- set field with variable of the same name | 206 | -- set field dengan variabel bernama sama |
| 207 | b = :<add>, value: 2 | 207 | b = :<add>, value: 2 |
| 208 | c = <add>: mt.__add, value: 3 | 208 | c = <add>: mt.__add, value: 3 |
| 209 | 209 | ||
| @@ -220,7 +220,7 @@ add = (right) => <>: mt, value: @value + right.value | |||
| 220 | mt.__add = add | 220 | mt.__add = add |
| 221 | 221 | ||
| 222 | a = <>: mt, value: 1 | 222 | a = <>: mt, value: 1 |
| 223 | -- set field with variable of the same name | 223 | -- set field dengan variabel bernama sama |
| 224 | b = :<add>, value: 2 | 224 | b = :<add>, value: 2 |
| 225 | c = <add>: mt.__add, value: 3 | 225 | c = <add>: mt.__add, value: 3 |
| 226 | 226 | ||
| @@ -232,12 +232,12 @@ close _ = <close>: -> print "out of scope" | |||
| 232 | 232 | ||
| 233 | </YueDisplay> | 233 | </YueDisplay> |
| 234 | 234 | ||
| 235 | ### Metatable Accessing | 235 | ### Mengakses Metatable |
| 236 | 236 | ||
| 237 | Accessing metatable with **<>** or metamethod name surrounded by **<>** or writing some expression in **<>**. | 237 | Akses metatable dengan **<>**, nama metamethod yang dikelilingi **<>**, atau menulis ekspresi di dalam **<>**. |
| 238 | 238 | ||
| 239 | ```yuescript | 239 | ```yuescript |
| 240 | -- create with metatable containing field "value" | 240 | -- dibuat dengan metatable yang berisi field "value" |
| 241 | tb = <"value">: 123 | 241 | tb = <"value">: 123 |
| 242 | tb.<index> = tb.<> | 242 | tb.<index> = tb.<> |
| 243 | print tb.value | 243 | print tb.value |
| @@ -248,7 +248,7 @@ print tb.item | |||
| 248 | <YueDisplay> | 248 | <YueDisplay> |
| 249 | 249 | ||
| 250 | ```yue | 250 | ```yue |
| 251 | -- create with metatable containing field "value" | 251 | -- dibuat dengan metatable yang berisi field "value" |
| 252 | tb = <"value">: 123 | 252 | tb = <"value">: 123 |
| 253 | tb.<index> = tb.<> | 253 | tb.<index> = tb.<> |
| 254 | print tb.value | 254 | print tb.value |
| @@ -258,9 +258,9 @@ print tb.item | |||
| 258 | 258 | ||
| 259 | </YueDisplay> | 259 | </YueDisplay> |
| 260 | 260 | ||
| 261 | ### Metatable Destructure | 261 | ### Destrukturisasi Metatable |
| 262 | 262 | ||
| 263 | Destruct metatable with metamethod key surrounded by **<>**. | 263 | Destrukturisasi metatable dengan kunci metamethod yang dikelilingi **<>**. |
| 264 | 264 | ||
| 265 | ```yuescript | 265 | ```yuescript |
| 266 | {item, :new, :<close>, <index>: getter} = tb | 266 | {item, :new, :<close>, <index>: getter} = tb |
| @@ -275,9 +275,9 @@ print item, new, close, getter | |||
| 275 | 275 | ||
| 276 | </YueDisplay> | 276 | </YueDisplay> |
| 277 | 277 | ||
| 278 | ## Existence | 278 | ## Keberadaan |
| 279 | 279 | ||
| 280 | The **?** operator can be used in a variety of contexts to check for existence. | 280 | Operator **?** dapat digunakan dalam berbagai konteks untuk memeriksa keberadaan. |
| 281 | 281 | ||
| 282 | ```yuescript | 282 | ```yuescript |
| 283 | func?! | 283 | func?! |
| @@ -314,14 +314,14 @@ with? io.open "test.txt", "w" | |||
| 314 | 314 | ||
| 315 | ## Piping | 315 | ## Piping |
| 316 | 316 | ||
| 317 | Instead of a series of nested function calls, you can pipe values with operator **|>**. | 317 | Sebagai ganti serangkaian pemanggilan fungsi bersarang, Anda bisa mengalirkan nilai dengan operator **|>**. |
| 318 | 318 | ||
| 319 | ```yuescript | 319 | ```yuescript |
| 320 | "hello" |> print | 320 | "hello" |> print |
| 321 | 1 |> print 2 -- insert pipe item as the first argument | 321 | 1 |> print 2 -- sisipkan nilai pipe sebagai argumen pertama |
| 322 | 2 |> print 1, _, 3 -- pipe with a placeholder | 322 | 2 |> print 1, _, 3 -- pipe dengan placeholder |
| 323 | 323 | ||
| 324 | -- pipe expression in multiline | 324 | -- ekspresi pipe multi-baris |
| 325 | readFile "example.txt" | 325 | readFile "example.txt" |
| 326 | |> extract language, {} | 326 | |> extract language, {} |
| 327 | |> parse language | 327 | |> parse language |
| @@ -333,9 +333,9 @@ readFile "example.txt" | |||
| 333 | 333 | ||
| 334 | ```yue | 334 | ```yue |
| 335 | "hello" |> print | 335 | "hello" |> print |
| 336 | 1 |> print 2 -- insert pipe item as the first argument | 336 | 1 |> print 2 -- sisipkan nilai pipe sebagai argumen pertama |
| 337 | 2 |> print 1, _, 3 -- pipe with a placeholder | 337 | 2 |> print 1, _, 3 -- pipe dengan placeholder |
| 338 | -- pipe expression in multiline | 338 | -- ekspresi pipe multi-baris |
| 339 | readFile "example.txt" | 339 | readFile "example.txt" |
| 340 | |> extract language, {} | 340 | |> extract language, {} |
| 341 | |> parse language | 341 | |> parse language |
| @@ -348,7 +348,7 @@ readFile "example.txt" | |||
| 348 | 348 | ||
| 349 | ## Nil Coalescing | 349 | ## Nil Coalescing |
| 350 | 350 | ||
| 351 | The nil-coalescing operator **??** returns the value of its left-hand operand if it isn't **nil**; otherwise, it evaluates the right-hand operand and returns its result. The **??** operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-nil. | 351 | Operator nil-coalescing **??** mengembalikan nilai dari operan kiri jika bukan **nil**; jika tidak, operator mengevaluasi operan kanan dan mengembalikan hasilnya. Operator **??** tidak mengevaluasi operan kanan jika operan kiri bernilai non-nil. |
| 352 | ```yuescript | 352 | ```yuescript |
| 353 | local a, b, c, d | 353 | local a, b, c, d |
| 354 | a = b ?? c ?? d | 354 | a = b ?? c ?? d |
| @@ -367,31 +367,31 @@ a ??= false | |||
| 367 | 367 | ||
| 368 | </YueDisplay> | 368 | </YueDisplay> |
| 369 | 369 | ||
| 370 | ## Implicit Object | 370 | ## Objek Implisit |
| 371 | 371 | ||
| 372 | You can write a list of implicit structures that starts with the symbol **\*** or **-** inside a table block. If you are creating implicit object, the fields of the object must be with the same indent. | 372 | Anda dapat menulis daftar struktur implisit yang diawali simbol **\*** atau **-** di dalam blok tabel. Jika Anda membuat objek implisit, field objek harus berada pada indentasi yang sama. |
| 373 | 373 | ||
| 374 | ```yuescript | 374 | ```yuescript |
| 375 | -- assignment with implicit object | 375 | -- assignment dengan objek implisit |
| 376 | list = | 376 | list = |
| 377 | * 1 | 377 | * 1 |
| 378 | * 2 | 378 | * 2 |
| 379 | * 3 | 379 | * 3 |
| 380 | 380 | ||
| 381 | -- function call with implicit object | 381 | -- pemanggilan fungsi dengan objek implisit |
| 382 | func | 382 | func |
| 383 | * 1 | 383 | * 1 |
| 384 | * 2 | 384 | * 2 |
| 385 | * 3 | 385 | * 3 |
| 386 | 386 | ||
| 387 | -- return with implicit object | 387 | -- return dengan objek implisit |
| 388 | f = -> | 388 | f = -> |
| 389 | return | 389 | return |
| 390 | * 1 | 390 | * 1 |
| 391 | * 2 | 391 | * 2 |
| 392 | * 3 | 392 | * 3 |
| 393 | 393 | ||
| 394 | -- table with implicit object | 394 | -- tabel dengan objek implisit |
| 395 | tb = | 395 | tb = |
| 396 | name: "abc" | 396 | name: "abc" |
| 397 | 397 | ||
| @@ -416,26 +416,26 @@ tb = | |||
| 416 | <YueDisplay> | 416 | <YueDisplay> |
| 417 | 417 | ||
| 418 | ```yue | 418 | ```yue |
| 419 | -- assignment with implicit object | 419 | -- assignment dengan objek implisit |
| 420 | list = | 420 | list = |
| 421 | * 1 | 421 | * 1 |
| 422 | * 2 | 422 | * 2 |
| 423 | * 3 | 423 | * 3 |
| 424 | 424 | ||
| 425 | -- function call with implicit object | 425 | -- pemanggilan fungsi dengan objek implisit |
| 426 | func | 426 | func |
| 427 | * 1 | 427 | * 1 |
| 428 | * 2 | 428 | * 2 |
| 429 | * 3 | 429 | * 3 |
| 430 | 430 | ||
| 431 | -- return with implicit object | 431 | -- return dengan objek implisit |
| 432 | f = -> | 432 | f = -> |
| 433 | return | 433 | return |
| 434 | * 1 | 434 | * 1 |
| 435 | * 2 | 435 | * 2 |
| 436 | * 3 | 436 | * 3 |
| 437 | 437 | ||
| 438 | -- table with implicit object | 438 | -- tabel dengan objek implisit |
| 439 | tb = | 439 | tb = |
| 440 | name: "abc" | 440 | name: "abc" |
| 441 | 441 | ||
diff --git a/doc/docs/id-id/doc/language-basics/whitespace.md b/doc/docs/id-id/doc/language-basics/whitespace.md index d742a2b..bdc124e 100644 --- a/doc/docs/id-id/doc/language-basics/whitespace.md +++ b/doc/docs/id-id/doc/language-basics/whitespace.md | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | # Whitespace | 1 | # Spasi Kosong |
| 2 | 2 | ||
| 3 | YueScript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. | 3 | YueScript adalah bahasa yang peka terhadap spasi. Anda harus menulis beberapa blok kode dengan indentasi yang sama menggunakan spasi **' '** atau tab **'\t'** seperti badan fungsi, daftar nilai, dan beberapa blok kontrol. Ekspresi yang mengandung spasi berbeda dapat bermakna berbeda. Tab diperlakukan seperti 4 spasi, tetapi sebaiknya jangan mencampur penggunaan spasi dan tab. |
| 4 | 4 | ||
| 5 | ## Statement Separator | 5 | ## Pemisah Pernyataan |
| 6 | 6 | ||
| 7 | A statement normally ends at a line break. You can also use a semicolon `;` to explicitly terminate a statement, which allows writing multiple statements on the same line: | 7 | Sebuah pernyataan biasanya berakhir pada pergantian baris. Anda juga bisa memakai titik koma `;` untuk mengakhiri pernyataan secara eksplisit, yang memungkinkan menulis beberapa pernyataan pada satu baris: |
| 8 | 8 | ||
| 9 | ```yuescript | 9 | ```yuescript |
| 10 | a = 1; b = 2; print a + b | 10 | a = 1; b = 2; print a + b |
| @@ -17,9 +17,9 @@ a = 1; b = 2; print a + b | |||
| 17 | 17 | ||
| 18 | </YueDisplay> | 18 | </YueDisplay> |
| 19 | 19 | ||
| 20 | ## Multiline Chaining | 20 | ## Rantai Multibaris |
| 21 | 21 | ||
| 22 | You can write multi-line chaining function calls with a same indent. | 22 | Anda bisa menulis pemanggilan fungsi berantai multi-baris dengan indentasi yang sama. |
| 23 | 23 | ||
| 24 | ```yuescript | 24 | ```yuescript |
| 25 | Rx.Observable | 25 | Rx.Observable |
diff --git a/doc/docs/id-id/doc/objects/object-oriented-programming.md b/doc/docs/id-id/doc/objects/object-oriented-programming.md index 6a8559e..96c19d7 100644 --- a/doc/docs/id-id/doc/objects/object-oriented-programming.md +++ b/doc/docs/id-id/doc/objects/object-oriented-programming.md | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | # Object Oriented Programming | 1 | # Pemrograman Berorientasi Objek |
| 2 | 2 | ||
| 3 | In these examples, the generated Lua code may appear overwhelming. It is best to focus on the meaning of the YueScript code at first, then look into the Lua code if you wish to know the implementation details. | 3 | Dalam contoh-contoh ini, kode Lua yang dihasilkan mungkin tampak berat. Sebaiknya fokus dulu pada makna kode YueScript, lalu lihat kode Lua jika Anda ingin mengetahui detail implementasinya. |
| 4 | 4 | ||
| 5 | A simple class: | 5 | Kelas sederhana: |
| 6 | 6 | ||
| 7 | ```yuescript | 7 | ```yuescript |
| 8 | class Inventory | 8 | class Inventory |
| @@ -31,15 +31,15 @@ class Inventory | |||
| 31 | 31 | ||
| 32 | </YueDisplay> | 32 | </YueDisplay> |
| 33 | 33 | ||
| 34 | A class is declared with a class statement followed by a table-like declaration where all of the methods and properties are listed. | 34 | Kelas dideklarasikan dengan pernyataan `class` diikuti deklarasi mirip tabel di mana semua method dan properti dicantumkan. |
| 35 | 35 | ||
| 36 | The new property is special in that it will become the constructor. | 36 | Properti `new` bersifat khusus karena akan menjadi konstruktor. |
| 37 | 37 | ||
| 38 | Notice how all the methods in the class use the fat arrow function syntax. When calling methods on a instance, the instance itself is sent in as the first argument. The fat arrow handles the creation of a self argument. | 38 | Perhatikan bahwa semua method di kelas menggunakan sintaks fungsi panah tebal. Saat memanggil method pada instance, instance itu sendiri dikirim sebagai argumen pertama. Panah tebal menangani pembuatan argumen `self`. |
| 39 | 39 | ||
| 40 | The @ prefix on a variable name is shorthand for self.. @items becomes self.items. | 40 | Prefiks `@` pada nama variabel adalah singkatan untuk `self.`. `@items` menjadi `self.items`. |
| 41 | 41 | ||
| 42 | Creating an instance of the class is done by calling the name of the class as a function. | 42 | Membuat instance kelas dilakukan dengan memanggil nama kelas sebagai fungsi. |
| 43 | 43 | ||
| 44 | ```yuescript | 44 | ```yuescript |
| 45 | inv = Inventory! | 45 | inv = Inventory! |
| @@ -56,11 +56,11 @@ inv\add_item "pants" | |||
| 56 | 56 | ||
| 57 | </YueDisplay> | 57 | </YueDisplay> |
| 58 | 58 | ||
| 59 | Because the instance of the class needs to be sent to the methods when they are called, the \ operator is used. | 59 | Karena instance kelas perlu dikirim ke method saat dipanggil, operator `\` digunakan. |
| 60 | 60 | ||
| 61 | All properties of a class are shared among the instances. This is fine for functions, but for other types of objects, undesired results may occur. | 61 | Semua properti kelas dibagikan di antara instance. Ini baik untuk fungsi, tetapi untuk jenis objek lain dapat menimbulkan hasil yang tidak diinginkan. |
| 62 | 62 | ||
| 63 | Consider the example below, the clothes property is shared amongst all instances, so modifications to it in one instance will show up in another: | 63 | Pertimbangkan contoh di bawah ini, properti `clothes` dibagikan di antara semua instance, sehingga perubahan di satu instance akan terlihat di instance lainnya: |
| 64 | 64 | ||
| 65 | ```yuescript | 65 | ```yuescript |
| 66 | class Person | 66 | class Person |
| @@ -74,7 +74,7 @@ b = Person! | |||
| 74 | a\give_item "pants" | 74 | a\give_item "pants" |
| 75 | b\give_item "shirt" | 75 | b\give_item "shirt" |
| 76 | 76 | ||
| 77 | -- will print both pants and shirt | 77 | -- akan mencetak pants dan shirt |
| 78 | print item for item in *a.clothes | 78 | print item for item in *a.clothes |
| 79 | ``` | 79 | ``` |
| 80 | <YueDisplay> | 80 | <YueDisplay> |
| @@ -91,13 +91,13 @@ b = Person! | |||
| 91 | a\give_item "pants" | 91 | a\give_item "pants" |
| 92 | b\give_item "shirt" | 92 | b\give_item "shirt" |
| 93 | 93 | ||
| 94 | -- will print both pants and shirt | 94 | -- akan mencetak pants dan shirt |
| 95 | print item for item in *a.clothes | 95 | print item for item in *a.clothes |
| 96 | ``` | 96 | ``` |
| 97 | 97 | ||
| 98 | </YueDisplay> | 98 | </YueDisplay> |
| 99 | 99 | ||
| 100 | The proper way to avoid this problem is to create the mutable state of the object in the constructor: | 100 | Cara yang benar untuk menghindari masalah ini adalah membuat state yang dapat berubah di konstruktor: |
| 101 | 101 | ||
| 102 | ```yuescript | 102 | ```yuescript |
| 103 | class Person | 103 | class Person |
| @@ -114,9 +114,9 @@ class Person | |||
| 114 | 114 | ||
| 115 | </YueDisplay> | 115 | </YueDisplay> |
| 116 | 116 | ||
| 117 | ## Inheritance | 117 | ## Pewarisan |
| 118 | 118 | ||
| 119 | The extends keyword can be used in a class declaration to inherit the properties and methods from another class. | 119 | Kata kunci `extends` dapat digunakan dalam deklarasi kelas untuk mewarisi properti dan method dari kelas lain. |
| 120 | 120 | ||
| 121 | ```yuescript | 121 | ```yuescript |
| 122 | class BackPack extends Inventory | 122 | class BackPack extends Inventory |
| @@ -137,18 +137,18 @@ class BackPack extends Inventory | |||
| 137 | 137 | ||
| 138 | </YueDisplay> | 138 | </YueDisplay> |
| 139 | 139 | ||
| 140 | Here we extend our Inventory class, and limit the amount of items it can carry. | 140 | Di sini kita memperluas kelas Inventory, dan membatasi jumlah item yang bisa dibawa. |
| 141 | 141 | ||
| 142 | In this example, we don't define a constructor on the subclass, so the parent class' constructor is called when we make a new instance. If we did define a constructor then we can use the super method to call the parent constructor. | 142 | Dalam contoh ini, kita tidak mendefinisikan konstruktor pada subclass, sehingga konstruktor kelas induk dipanggil ketika membuat instance baru. Jika kita mendefinisikan konstruktor, kita bisa menggunakan method `super` untuk memanggil konstruktor induk. |
| 143 | 143 | ||
| 144 | Whenever a class inherits from another, it sends a message to the parent class by calling the method __inherited on the parent class if it exists. The function receives two arguments, the class that is being inherited and the child class. | 144 | Setiap kali sebuah kelas mewarisi dari kelas lain, ia mengirim pesan ke kelas induk dengan memanggil method `__inherited` pada kelas induk jika ada. Fungsi menerima dua argumen, kelas yang diwarisi dan kelas anak. |
| 145 | 145 | ||
| 146 | ```yuescript | 146 | ```yuescript |
| 147 | class Shelf | 147 | class Shelf |
| 148 | @__inherited: (child) => | 148 | @__inherited: (child) => |
| 149 | print @__name, "was inherited by", child.__name | 149 | print @__name, "was inherited by", child.__name |
| 150 | 150 | ||
| 151 | -- will print: Shelf was inherited by Cupboard | 151 | -- akan mencetak: Shelf was inherited by Cupboard |
| 152 | class Cupboard extends Shelf | 152 | class Cupboard extends Shelf |
| 153 | ``` | 153 | ``` |
| 154 | <YueDisplay> | 154 | <YueDisplay> |
| @@ -158,7 +158,7 @@ class Shelf | |||
| 158 | @__inherited: (child) => | 158 | @__inherited: (child) => |
| 159 | print @__name, "was inherited by", child.__name | 159 | print @__name, "was inherited by", child.__name |
| 160 | 160 | ||
| 161 | -- will print: Shelf was inherited by Cupboard | 161 | -- akan mencetak: Shelf was inherited by Cupboard |
| 162 | class Cupboard extends Shelf | 162 | class Cupboard extends Shelf |
| 163 | ``` | 163 | ``` |
| 164 | 164 | ||
| @@ -166,27 +166,27 @@ class Cupboard extends Shelf | |||
| 166 | 166 | ||
| 167 | ## Super | 167 | ## Super |
| 168 | 168 | ||
| 169 | **super** is a special keyword that can be used in two different ways: It can be treated as an object, or it can be called like a function. It only has special functionality when inside a class. | 169 | **super** adalah kata kunci khusus yang dapat digunakan dengan dua cara: sebagai objek, atau dipanggil seperti fungsi. Ia hanya memiliki fungsi khusus ketika berada di dalam kelas. |
| 170 | 170 | ||
| 171 | When called as a function, it will call the function of the same name in the parent class. The current self will automatically be passed as the first argument. (As seen in the inheritance example above) | 171 | Ketika dipanggil sebagai fungsi, ia akan memanggil fungsi dengan nama yang sama di kelas induk. `self` saat ini akan otomatis dikirim sebagai argumen pertama. (Seperti pada contoh pewarisan di atas) |
| 172 | 172 | ||
| 173 | When super is used as a normal value, it is a reference to the parent class object. | 173 | Ketika `super` digunakan sebagai nilai normal, ia merupakan referensi ke objek kelas induk. |
| 174 | 174 | ||
| 175 | It can be accessed like any of object in order to retrieve values in the parent class that might have been shadowed by the child class. | 175 | Ia dapat diakses seperti objek biasa untuk mengambil nilai di kelas induk yang mungkin tertutup oleh kelas anak. |
| 176 | 176 | ||
| 177 | When the \ calling operator is used with super, self is inserted as the first argument instead of the value of super itself. When using . to retrieve a function, the raw function is returned. | 177 | Ketika operator pemanggilan `\` digunakan dengan `super`, `self` disisipkan sebagai argumen pertama alih-alih nilai `super` itu sendiri. Saat menggunakan `.` untuk mengambil fungsi, fungsi mentah dikembalikan. |
| 178 | 178 | ||
| 179 | A few examples of using super in different ways: | 179 | Beberapa contoh penggunaan `super` dengan cara berbeda: |
| 180 | 180 | ||
| 181 | ```yuescript | 181 | ```yuescript |
| 182 | class MyClass extends ParentClass | 182 | class MyClass extends ParentClass |
| 183 | a_method: => | 183 | a_method: => |
| 184 | -- the following have the same effect: | 184 | -- berikut memiliki efek yang sama: |
| 185 | super "hello", "world" | 185 | super "hello", "world" |
| 186 | super\a_method "hello", "world" | 186 | super\a_method "hello", "world" |
| 187 | super.a_method self, "hello", "world" | 187 | super.a_method self, "hello", "world" |
| 188 | 188 | ||
| 189 | -- super as a value is equal to the parent class: | 189 | -- super sebagai nilai sama dengan kelas induk: |
| 190 | assert super == ParentClass | 190 | assert super == ParentClass |
| 191 | ``` | 191 | ``` |
| 192 | <YueDisplay> | 192 | <YueDisplay> |
| @@ -194,28 +194,28 @@ class MyClass extends ParentClass | |||
| 194 | ```yue | 194 | ```yue |
| 195 | class MyClass extends ParentClass | 195 | class MyClass extends ParentClass |
| 196 | a_method: => | 196 | a_method: => |
| 197 | -- the following have the same effect: | 197 | -- berikut memiliki efek yang sama: |
| 198 | super "hello", "world" | 198 | super "hello", "world" |
| 199 | super\a_method "hello", "world" | 199 | super\a_method "hello", "world" |
| 200 | super.a_method self, "hello", "world" | 200 | super.a_method self, "hello", "world" |
| 201 | 201 | ||
| 202 | -- super as a value is equal to the parent class: | 202 | -- super sebagai nilai sama dengan kelas induk: |
| 203 | assert super == ParentClass | 203 | assert super == ParentClass |
| 204 | ``` | 204 | ``` |
| 205 | 205 | ||
| 206 | </YueDisplay> | 206 | </YueDisplay> |
| 207 | 207 | ||
| 208 | **super** can also be used on left side of a Function Stub. The only major difference is that instead of the resulting function being bound to the value of super, it is bound to self. | 208 | **super** juga dapat digunakan di sisi kiri Function Stub. Perbedaan utamanya adalah, alih-alih fungsi hasil terikat pada nilai `super`, fungsi terikat pada `self`. |
| 209 | 209 | ||
| 210 | ## Types | 210 | ## Tipe |
| 211 | 211 | ||
| 212 | Every instance of a class carries its type with it. This is stored in the special __class property. This property holds the class object. The class object is what we call to build a new instance. We can also index the class object to retrieve class methods and properties. | 212 | Setiap instance kelas membawa tipenya sendiri. Ini disimpan di properti khusus `__class`. Properti ini memuat objek kelas. Objek kelas adalah yang kita panggil untuk membuat instance baru. Kita juga dapat mengindeks objek kelas untuk mengambil method dan properti kelas. |
| 213 | 213 | ||
| 214 | ```yuescript | 214 | ```yuescript |
| 215 | b = BackPack! | 215 | b = BackPack! |
| 216 | assert b.__class == BackPack | 216 | assert b.__class == BackPack |
| 217 | 217 | ||
| 218 | print BackPack.size -- prints 10 | 218 | print BackPack.size -- mencetak 10 |
| 219 | ``` | 219 | ``` |
| 220 | <YueDisplay> | 220 | <YueDisplay> |
| 221 | 221 | ||
| @@ -223,45 +223,45 @@ print BackPack.size -- prints 10 | |||
| 223 | b = BackPack! | 223 | b = BackPack! |
| 224 | assert b.__class == BackPack | 224 | assert b.__class == BackPack |
| 225 | 225 | ||
| 226 | print BackPack.size -- prints 10 | 226 | print BackPack.size -- mencetak 10 |
| 227 | ``` | 227 | ``` |
| 228 | 228 | ||
| 229 | </YueDisplay> | 229 | </YueDisplay> |
| 230 | 230 | ||
| 231 | ## Class Objects | 231 | ## Objek Kelas |
| 232 | 232 | ||
| 233 | The class object is what we create when we use a class statement. The class object is stored in a variable of the same name of the class. | 233 | Objek kelas adalah yang kita buat saat menggunakan pernyataan `class`. Objek kelas disimpan dalam variabel dengan nama yang sama dengan kelas. |
| 234 | 234 | ||
| 235 | The class object can be called like a function in order to create new instances. That's how we created instances of classes in the examples above. | 235 | Objek kelas dapat dipanggil seperti fungsi untuk membuat instance baru. Begitulah cara kita membuat instance kelas pada contoh di atas. |
| 236 | 236 | ||
| 237 | A class is made up of two tables. The class table itself, and the base table. The base is used as the metatable for all the instances. All properties listed in the class declaration are placed in the base. | 237 | Sebuah kelas terdiri dari dua tabel: tabel kelas itu sendiri dan tabel base. Base digunakan sebagai metatable untuk semua instance. Semua properti yang dicantumkan dalam deklarasi kelas ditempatkan di base. |
| 238 | 238 | ||
| 239 | The class object's metatable reads properties from the base if they don't exist in the class object. This means we can access functions and properties directly from the class. | 239 | Metatable objek kelas membaca properti dari base jika tidak ada di objek kelas. Ini berarti kita dapat mengakses fungsi dan properti langsung dari kelas. |
| 240 | 240 | ||
| 241 | It is important to note that assigning to the class object does not assign into the base, so it's not a valid way to add new methods to instances. Instead the base must explicitly be changed. See the __base field below. | 241 | Penting untuk dicatat bahwa assignment ke objek kelas tidak meng-assign ke base, sehingga itu bukan cara yang valid untuk menambahkan method baru ke instance. Sebagai gantinya, base harus diubah secara eksplisit. Lihat field `__base` di bawah. |
| 242 | 242 | ||
| 243 | The class object has a couple special properties: | 243 | Objek kelas memiliki beberapa properti khusus: |
| 244 | 244 | ||
| 245 | The name of the class as when it was declared is stored as a string in the __name field of the class object. | 245 | Nama kelas saat dideklarasikan disimpan sebagai string di field `__name` pada objek kelas. |
| 246 | 246 | ||
| 247 | ```yuescript | 247 | ```yuescript |
| 248 | print BackPack.__name -- prints Backpack | 248 | print BackPack.__name -- mencetak Backpack |
| 249 | ``` | 249 | ``` |
| 250 | <YueDisplay> | 250 | <YueDisplay> |
| 251 | 251 | ||
| 252 | ```yue | 252 | ```yue |
| 253 | print BackPack.__name -- prints Backpack | 253 | print BackPack.__name -- mencetak Backpack |
| 254 | ``` | 254 | ``` |
| 255 | 255 | ||
| 256 | </YueDisplay> | 256 | </YueDisplay> |
| 257 | 257 | ||
| 258 | The base object is stored in __base. We can modify this table to add functionality to instances that have already been created and ones that are yet to be created. | 258 | Objek base disimpan di `__base`. Kita dapat memodifikasi tabel ini untuk menambahkan fungsionalitas ke instance yang sudah dibuat maupun yang akan dibuat. |
| 259 | 259 | ||
| 260 | If the class extends from anything, the parent class object is stored in __parent. | 260 | Jika kelas memperluas kelas lain, objek kelas induk disimpan di `__parent`. |
| 261 | 261 | ||
| 262 | ## Class Variables | 262 | ## Variabel Kelas |
| 263 | 263 | ||
| 264 | We can create variables directly in the class object instead of in the base by using @ in the front of the property name in a class declaration. | 264 | Kita dapat membuat variabel langsung di objek kelas alih-alih di base dengan menggunakan `@` di depan nama properti pada deklarasi kelas. |
| 265 | 265 | ||
| 266 | ```yuescript | 266 | ```yuescript |
| 267 | class Things | 267 | class Things |
| @@ -269,7 +269,7 @@ class Things | |||
| 269 | 269 | ||
| 270 | Things\some_func! | 270 | Things\some_func! |
| 271 | 271 | ||
| 272 | -- class variables not visible in instances | 272 | -- variabel kelas tidak terlihat pada instance |
| 273 | assert Things().some_func == nil | 273 | assert Things().some_func == nil |
| 274 | ``` | 274 | ``` |
| 275 | <YueDisplay> | 275 | <YueDisplay> |
| @@ -280,13 +280,13 @@ class Things | |||
| 280 | 280 | ||
| 281 | Things\some_func! | 281 | Things\some_func! |
| 282 | 282 | ||
| 283 | -- class variables not visible in instances | 283 | -- variabel kelas tidak terlihat pada instance |
| 284 | assert Things().some_func == nil | 284 | assert Things().some_func == nil |
| 285 | ``` | 285 | ``` |
| 286 | 286 | ||
| 287 | </YueDisplay> | 287 | </YueDisplay> |
| 288 | 288 | ||
| 289 | In expressions, we can use @@ to access a value that is stored in the __class of self. Thus, @@hello is shorthand for self.__class.hello. | 289 | Dalam ekspresi, kita dapat menggunakan `@@` untuk mengakses nilai yang disimpan di `__class` milik `self`. Jadi, `@@hello` adalah singkatan dari `self.__class.hello`. |
| 290 | 290 | ||
| 291 | ```yuescript | 291 | ```yuescript |
| 292 | class Counter | 292 | class Counter |
| @@ -298,7 +298,7 @@ class Counter | |||
| 298 | Counter! | 298 | Counter! |
| 299 | Counter! | 299 | Counter! |
| 300 | 300 | ||
| 301 | print Counter.count -- prints 2 | 301 | print Counter.count -- mencetak 2 |
| 302 | ``` | 302 | ``` |
| 303 | <YueDisplay> | 303 | <YueDisplay> |
| 304 | 304 | ||
| @@ -312,12 +312,12 @@ class Counter | |||
| 312 | Counter! | 312 | Counter! |
| 313 | Counter! | 313 | Counter! |
| 314 | 314 | ||
| 315 | print Counter.count -- prints 2 | 315 | print Counter.count -- mencetak 2 |
| 316 | ``` | 316 | ``` |
| 317 | 317 | ||
| 318 | </YueDisplay> | 318 | </YueDisplay> |
| 319 | 319 | ||
| 320 | The calling semantics of @@ are similar to @. Calling a @@ name will pass the class in as the first argument using Lua's colon syntax. | 320 | Semantik pemanggilan `@@` mirip dengan `@`. Memanggil nama `@@` akan meneruskan kelas sebagai argumen pertama menggunakan sintaks kolon Lua. |
| 321 | 321 | ||
| 322 | ```yuescript | 322 | ```yuescript |
| 323 | @@hello 1,2,3,4 | 323 | @@hello 1,2,3,4 |
| @@ -330,11 +330,11 @@ The calling semantics of @@ are similar to @. Calling a @@ name will pass the cl | |||
| 330 | 330 | ||
| 331 | </YueDisplay> | 331 | </YueDisplay> |
| 332 | 332 | ||
| 333 | ## Class Declaration Statements | 333 | ## Pernyataan Deklarasi Kelas |
| 334 | 334 | ||
| 335 | In the body of a class declaration, we can have normal expressions in addition to key/value pairs. In this context, self is equal to the class object. | 335 | Di dalam badan deklarasi kelas, kita bisa memiliki ekspresi normal selain pasangan key/value. Dalam konteks ini, `self` sama dengan objek kelas. |
| 336 | 336 | ||
| 337 | Here is an alternative way to create a class variable compared to what's described above: | 337 | Berikut cara alternatif untuk membuat variabel kelas dibandingkan yang dijelaskan di atas: |
| 338 | 338 | ||
| 339 | ```yuescript | 339 | ```yuescript |
| 340 | class Things | 340 | class Things |
| @@ -349,9 +349,9 @@ class Things | |||
| 349 | 349 | ||
| 350 | </YueDisplay> | 350 | </YueDisplay> |
| 351 | 351 | ||
| 352 | These expressions are executed after all the properties have been added to the base. | 352 | Ekspresi ini dieksekusi setelah semua properti ditambahkan ke base. |
| 353 | 353 | ||
| 354 | All variables declared in the body of the class are local to the classes properties. This is convenient for placing private values or helper functions that only the class methods can access: | 354 | Semua variabel yang dideklarasikan di badan kelas bersifat lokal terhadap properti kelas. Ini berguna untuk menempatkan nilai privat atau fungsi pembantu yang hanya dapat diakses oleh method kelas: |
| 355 | 355 | ||
| 356 | ```yuescript | 356 | ```yuescript |
| 357 | class MoreThings | 357 | class MoreThings |
| @@ -374,11 +374,11 @@ class MoreThings | |||
| 374 | 374 | ||
| 375 | </YueDisplay> | 375 | </YueDisplay> |
| 376 | 376 | ||
| 377 | ## @ and @@ Values | 377 | ## Nilai @ dan @@ |
| 378 | 378 | ||
| 379 | When @ and @@ are prefixed in front of a name they represent, respectively, that name accessed in self and self.__class. | 379 | Ketika `@` dan `@@` diprefiks di depan sebuah nama, masing-masing merepresentasikan nama tersebut yang diakses di `self` dan `self.__class`. |
| 380 | 380 | ||
| 381 | If they are used all by themselves, they are aliases for self and self.__class. | 381 | Jika digunakan sendirian, keduanya adalah alias untuk `self` dan `self.__class`. |
| 382 | 382 | ||
| 383 | ```yuescript | 383 | ```yuescript |
| 384 | assert @ == self | 384 | assert @ == self |
| @@ -393,7 +393,7 @@ assert @@ == self.__class | |||
| 393 | 393 | ||
| 394 | </YueDisplay> | 394 | </YueDisplay> |
| 395 | 395 | ||
| 396 | For example, a quick way to create a new instance of the same class from an instance method using @@: | 396 | Contohnya, cara cepat untuk membuat instance baru dari kelas yang sama dari method instance menggunakan `@@`: |
| 397 | 397 | ||
| 398 | ```yuescript | 398 | ```yuescript |
| 399 | some_instance_method = (...) => @@ ... | 399 | some_instance_method = (...) => @@ ... |
| @@ -406,15 +406,15 @@ some_instance_method = (...) => @@ ... | |||
| 406 | 406 | ||
| 407 | </YueDisplay> | 407 | </YueDisplay> |
| 408 | 408 | ||
| 409 | ## Constructor Property Promotion | 409 | ## Promosi Properti Konstruktor |
| 410 | 410 | ||
| 411 | To reduce the boilerplate code for definition of simple value objects. You can write a simple class like: | 411 | Untuk mengurangi boilerplate saat mendefinisikan objek nilai sederhana, Anda dapat menulis kelas sederhana seperti: |
| 412 | 412 | ||
| 413 | ```yuescript | 413 | ```yuescript |
| 414 | class Something | 414 | class Something |
| 415 | new: (@foo, @bar, @@biz, @@baz) => | 415 | new: (@foo, @bar, @@biz, @@baz) => |
| 416 | 416 | ||
| 417 | -- Which is short for | 417 | -- Yang merupakan singkatan dari |
| 418 | 418 | ||
| 419 | class Something | 419 | class Something |
| 420 | new: (foo, bar, biz, baz) => | 420 | new: (foo, bar, biz, baz) => |
| @@ -429,7 +429,7 @@ class Something | |||
| 429 | class Something | 429 | class Something |
| 430 | new: (@foo, @bar, @@biz, @@baz) => | 430 | new: (@foo, @bar, @@biz, @@baz) => |
| 431 | 431 | ||
| 432 | -- Which is short for | 432 | -- Yang merupakan singkatan dari |
| 433 | 433 | ||
| 434 | class Something | 434 | class Something |
| 435 | new: (foo, bar, biz, baz) => | 435 | new: (foo, bar, biz, baz) => |
| @@ -441,7 +441,7 @@ class Something | |||
| 441 | 441 | ||
| 442 | </YueDisplay> | 442 | </YueDisplay> |
| 443 | 443 | ||
| 444 | You can also use this syntax for a common function to initialize a object's fields. | 444 | Anda juga bisa menggunakan sintaks ini untuk fungsi umum guna menginisialisasi field objek. |
| 445 | 445 | ||
| 446 | ```yuescript | 446 | ```yuescript |
| 447 | new = (@fieldA, @fieldB) => @ | 447 | new = (@fieldA, @fieldB) => @ |
| @@ -458,9 +458,9 @@ print obj | |||
| 458 | 458 | ||
| 459 | </YueDisplay> | 459 | </YueDisplay> |
| 460 | 460 | ||
| 461 | ## Class Expressions | 461 | ## Ekspresi Kelas |
| 462 | 462 | ||
| 463 | The class syntax can also be used as an expression which can be assigned to a variable or explicitly returned. | 463 | Sintaks kelas juga bisa digunakan sebagai ekspresi yang dapat di-assign ke variabel atau di-return secara eksplisit. |
| 464 | 464 | ||
| 465 | ```yuescript | 465 | ```yuescript |
| 466 | x = class Bucket | 466 | x = class Bucket |
| @@ -477,9 +477,9 @@ x = class Bucket | |||
| 477 | 477 | ||
| 478 | </YueDisplay> | 478 | </YueDisplay> |
| 479 | 479 | ||
| 480 | ## Anonymous classes | 480 | ## Kelas Anonim |
| 481 | 481 | ||
| 482 | The name can be left out when declaring a class. The __name attribute will be nil, unless the class expression is in an assignment. The name on the left hand side of the assignment is used instead of nil. | 482 | Nama bisa dihilangkan saat mendeklarasikan kelas. Atribut `__name` akan bernilai nil, kecuali ekspresi kelas berada dalam assignment. Nama di sisi kiri assignment digunakan sebagai ganti nil. |
| 483 | 483 | ||
| 484 | ```yuescript | 484 | ```yuescript |
| 485 | BigBucket = class extends Bucket | 485 | BigBucket = class extends Bucket |
| @@ -498,7 +498,7 @@ assert Bucket.__name == "BigBucket" | |||
| 498 | 498 | ||
| 499 | </YueDisplay> | 499 | </YueDisplay> |
| 500 | 500 | ||
| 501 | You can even leave off the body, meaning you can write a blank anonymous class like this: | 501 | Anda bahkan bisa menghilangkan badan kelas, artinya Anda bisa menulis kelas anonim kosong seperti ini: |
| 502 | 502 | ||
| 503 | ```yuescript | 503 | ```yuescript |
| 504 | x = class | 504 | x = class |
| @@ -511,9 +511,9 @@ x = class | |||
| 511 | 511 | ||
| 512 | </YueDisplay> | 512 | </YueDisplay> |
| 513 | 513 | ||
| 514 | ## Class Mixing | 514 | ## Pencampuran Kelas |
| 515 | 515 | ||
| 516 | You can do mixing with keyword `using` to copy functions from either a plain table or a predefined class object into your new class. When doing mixing with a plain table, you can override the class indexing function (metamethod `__index`) to your customized implementation. When doing mixing with an existing class object, the class object's metamethods won't be copied. | 516 | Anda bisa melakukan mixing dengan kata kunci `using` untuk menyalin fungsi dari tabel biasa atau objek kelas yang sudah didefinisikan ke kelas baru Anda. Saat mixing dengan tabel biasa, Anda dapat mengganti fungsi pengindeksan kelas (metamethod `__index`) dengan implementasi kustom. Saat mixing dengan objek kelas yang sudah ada, metamethod objek kelas tidak akan disalin. |
| 517 | 517 | ||
| 518 | ```yuescript | 518 | ```yuescript |
| 519 | MyIndex = __index: var: 1 | 519 | MyIndex = __index: var: 1 |
| @@ -530,7 +530,7 @@ class Y using X | |||
| 530 | y = Y! | 530 | y = Y! |
| 531 | y\func! | 531 | y\func! |
| 532 | 532 | ||
| 533 | assert y.__class.__parent ~= X -- X is not parent of Y | 533 | assert y.__class.__parent ~= X -- X bukan parent dari Y |
| 534 | ``` | 534 | ``` |
| 535 | <YueDisplay> | 535 | <YueDisplay> |
| 536 | 536 | ||
| @@ -549,7 +549,7 @@ class Y using X | |||
| 549 | y = Y! | 549 | y = Y! |
| 550 | y\func! | 550 | y\func! |
| 551 | 551 | ||
| 552 | assert y.__class.__parent ~= X -- X is not parent of Y | 552 | assert y.__class.__parent ~= X -- X bukan parent dari Y |
| 553 | ``` | 553 | ``` |
| 554 | 554 | ||
| 555 | </YueDisplay> | 555 | </YueDisplay> |
diff --git a/doc/docs/id-id/doc/objects/with-statement.md b/doc/docs/id-id/doc/objects/with-statement.md index 7786803..3c0a8a5 100644 --- a/doc/docs/id-id/doc/objects/with-statement.md +++ b/doc/docs/id-id/doc/objects/with-statement.md | |||
| @@ -1,13 +1,12 @@ | |||
| 1 | # With Statement | 1 | # Pernyataan With |
| 2 | 2 | ||
| 3 | Pola umum saat membuat objek adalah memanggil serangkaian fungsi dan mengatur serangkaian properti segera setelah objek dibuat. | ||
| 3 | 4 | ||
| 4 | A common pattern involving the creation of an object is calling a series of functions and setting a series of properties immediately after creating it. | 5 | Hal ini menyebabkan nama objek diulang berkali-kali di kode, menambah noise yang tidak perlu. Solusi umum untuk ini adalah meneruskan tabel sebagai argumen yang berisi kumpulan kunci dan nilai untuk ditimpa. Kekurangannya adalah konstruktor objek harus mendukung bentuk ini. |
| 5 | 6 | ||
| 6 | This results in repeating the name of the object multiple times in code, adding unnecessary noise. A common solution to this is to pass a table in as an argument which contains a collection of keys and values to overwrite. The downside to this is that the constructor of this object must support this form. | 7 | Blok `with` membantu mengatasi hal ini. Di dalam blok `with`, kita bisa menggunakan pernyataan khusus yang diawali dengan `.` atau `\` yang merepresentasikan operasi tersebut diterapkan pada objek yang sedang dipakai. |
| 7 | 8 | ||
| 8 | The with block helps to alleviate this. Within a with block we can use a special statements that begin with either . or \ which represent those operations applied to the object we are using with on. | 9 | Sebagai contoh, kita bekerja dengan objek yang baru dibuat: |
| 9 | |||
| 10 | For example, we work with a newly created object: | ||
| 11 | 10 | ||
| 12 | ```yuescript | 11 | ```yuescript |
| 13 | with Person! | 12 | with Person! |
| @@ -28,7 +27,7 @@ with Person! | |||
| 28 | 27 | ||
| 29 | </YueDisplay> | 28 | </YueDisplay> |
| 30 | 29 | ||
| 31 | The with statement can also be used as an expression which returns the value it has been giving access to. | 30 | Pernyataan `with` juga bisa digunakan sebagai ekspresi yang mengembalikan nilai yang diberi akses. |
| 32 | 31 | ||
| 33 | ```yuescript | 32 | ```yuescript |
| 34 | file = with File "favorite_foods.txt" | 33 | file = with File "favorite_foods.txt" |
| @@ -43,7 +42,7 @@ file = with File "favorite_foods.txt" | |||
| 43 | 42 | ||
| 44 | </YueDisplay> | 43 | </YueDisplay> |
| 45 | 44 | ||
| 46 | Or… | 45 | Atau… |
| 47 | 46 | ||
| 48 | ```yuescript | 47 | ```yuescript |
| 49 | create_person = (name, relatives) -> | 48 | create_person = (name, relatives) -> |
| @@ -66,9 +65,9 @@ me = create_person "Leaf", [dad, mother, sister] | |||
| 66 | 65 | ||
| 67 | </YueDisplay> | 66 | </YueDisplay> |
| 68 | 67 | ||
| 69 | In this usage, with can be seen as a special form of the K combinator. | 68 | Dalam penggunaan ini, `with` dapat dilihat sebagai bentuk khusus dari kombinator K. |
| 70 | 69 | ||
| 71 | The expression in the with statement can also be an assignment, if you want to give a name to the expression. | 70 | Ekspresi pada pernyataan `with` juga bisa berupa assignment jika Anda ingin memberi nama pada ekspresi tersebut. |
| 72 | 71 | ||
| 73 | ```yuescript | 72 | ```yuescript |
| 74 | with str := "Hello" | 73 | with str := "Hello" |
| @@ -85,7 +84,7 @@ with str := "Hello" | |||
| 85 | 84 | ||
| 86 | </YueDisplay> | 85 | </YueDisplay> |
| 87 | 86 | ||
| 88 | You can access special keys with `[]` in a `with` statement. | 87 | Anda bisa mengakses kunci khusus dengan `[]` di dalam pernyataan `with`. |
| 89 | 88 | ||
| 90 | ```yuescript | 89 | ```yuescript |
| 91 | with tb | 90 | with tb |
| @@ -94,7 +93,7 @@ with tb | |||
| 94 | with [abc] | 93 | with [abc] |
| 95 | [3] = [2]\func! | 94 | [3] = [2]\func! |
| 96 | ["key-name"] = value | 95 | ["key-name"] = value |
| 97 | [] = "abc" -- appending to "tb" | 96 | [] = "abc" -- menambahkan ke "tb" |
| 98 | ``` | 97 | ``` |
| 99 | <YueDisplay> | 98 | <YueDisplay> |
| 100 | 99 | ||
| @@ -105,12 +104,12 @@ with tb | |||
| 105 | with [abc] | 104 | with [abc] |
| 106 | [3] = [2]\func! | 105 | [3] = [2]\func! |
| 107 | ["key-name"] = value | 106 | ["key-name"] = value |
| 108 | [] = "abc" -- appending to "tb" | 107 | [] = "abc" -- menambahkan ke "tb" |
| 109 | ``` | 108 | ``` |
| 110 | 109 | ||
| 111 | </YueDisplay> | 110 | </YueDisplay> |
| 112 | 111 | ||
| 113 | `with?` is an enhanced version of `with` syntax, which introduces an existential check to safely access objects that may be nil without explicit null checks. | 112 | `with?` adalah versi yang ditingkatkan dari sintaks `with`, yang memperkenalkan pengecekan keberadaan untuk mengakses objek yang mungkin nil secara aman tanpa pemeriksaan null eksplisit. |
| 114 | 113 | ||
| 115 | ```yuescript | 114 | ```yuescript |
| 116 | with? obj | 115 | with? obj |
diff --git a/doc/docs/id-id/doc/reference/license-mit.md b/doc/docs/id-id/doc/reference/license-mit.md index f1d5d60..5289f50 100644 --- a/doc/docs/id-id/doc/reference/license-mit.md +++ b/doc/docs/id-id/doc/reference/license-mit.md | |||
| @@ -1,23 +1,22 @@ | |||
| 1 | # License: MIT | 1 | # Lisensi: MIT |
| 2 | 2 | ||
| 3 | Copyright (c) 2017-2026 Li Jin \<dragon-fly@qq.com\> | 3 | Copyright (c) 2017-2026 Li Jin <dragon-fly@qq.com> |
| 4 | 4 | ||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | 5 | Izin dengan ini diberikan, tanpa biaya, kepada siapa pun yang memperoleh salinan |
| 6 | of this software and associated documentation files (the "Software"), to deal | 6 | perangkat lunak ini beserta file dokumentasi terkait ("Perangkat Lunak"), untuk |
| 7 | in the Software without restriction, including without limitation the rights | 7 | berurusan dengan Perangkat Lunak tanpa pembatasan, termasuk tanpa batasan hak |
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 8 | untuk menggunakan, menyalin, memodifikasi, menggabungkan, menerbitkan, |
| 9 | copies of the Software, and to permit persons to whom the Software is | 9 | mendistribusikan, mensublisensikan, dan/atau menjual salinan Perangkat Lunak, |
| 10 | furnished to do so, subject to the following conditions: | 10 | dan untuk mengizinkan orang yang menerima Perangkat Lunak untuk melakukannya, |
| 11 | dengan syarat-syarat berikut: | ||
| 11 | 12 | ||
| 12 | The above copyright notice and this permission notice shall be included in all | 13 | Pemberitahuan hak cipta di atas dan pemberitahuan izin ini harus disertakan dalam |
| 13 | copies or substantial portions of the Software. | 14 | semua salinan atau bagian substansial dari Perangkat Lunak. |
| 14 | 15 | ||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | PERANGKAT LUNAK DISEDIAKAN "APA ADANYA", TANPA JAMINAN APA PUN, BAIK TERSURAT |
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | MAUPUN TERSIRAT, TERMASUK NAMUN TIDAK TERBATAS PADA JAMINAN KELAYAKAN |
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | DIPERDAGANGKAN, KESESUAIAN UNTUK TUJUAN TERTENTU, DAN TIDAK MELANGGAR HAK. |
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 19 | DALAM KEADAAN APA PUN, PENULIS ATAU PEMEGANG HAK CIPTA TIDAK BERTANGGUNG JAWAB |
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 20 | ATAS KLAIM, KERUSAKAN, ATAU KEWAJIBAN LAINNYA, BAIK DALAM TINDAKAN KONTRAK, |
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 21 | PERBUATAN MELAWAN HUKUM, ATAU LAINNYA, YANG TIMBUL DARI, DI LUAR, ATAU TERKAIT |
| 21 | SOFTWARE. | 22 | DENGAN PERANGKAT LUNAK ATAU PENGGUNAAN ATAU URUSAN LAIN DALAM PERANGKAT LUNAK. |
| 22 | |||
| 23 | <CompilerModal /> | ||
diff --git a/doc/docs/id-id/doc/reference/the-yuescript-library.md b/doc/docs/id-id/doc/reference/the-yuescript-library.md index 3761755..0a398a5 100644 --- a/doc/docs/id-id/doc/reference/the-yuescript-library.md +++ b/doc/docs/id-id/doc/reference/the-yuescript-library.md | |||
| @@ -1,20 +1,20 @@ | |||
| 1 | # The YueScript Library | 1 | # Pustaka YueScript |
| 2 | 2 | ||
| 3 | Access it by `local yue = require("yue")` in Lua. | 3 | Akses dengan `local yue = require("yue")` di Lua. |
| 4 | 4 | ||
| 5 | ## yue | 5 | ## yue |
| 6 | 6 | ||
| 7 | **Description:** | 7 | **Deskripsi:** |
| 8 | 8 | ||
| 9 | The YueScript language library. | 9 | Pustaka bahasa YueScript. |
| 10 | 10 | ||
| 11 | ### version | 11 | ### version |
| 12 | 12 | ||
| 13 | **Type:** Field. | 13 | **Tipe:** Field. |
| 14 | 14 | ||
| 15 | **Description:** | 15 | **Deskripsi:** |
| 16 | 16 | ||
| 17 | The YueScript version. | 17 | Versi YueScript. |
| 18 | 18 | ||
| 19 | **Signature:** | 19 | **Signature:** |
| 20 | ```lua | 20 | ```lua |
| @@ -23,11 +23,11 @@ version: string | |||
| 23 | 23 | ||
| 24 | ### dirsep | 24 | ### dirsep |
| 25 | 25 | ||
| 26 | **Type:** Field. | 26 | **Tipe:** Field. |
| 27 | 27 | ||
| 28 | **Description:** | 28 | **Deskripsi:** |
| 29 | 29 | ||
| 30 | The file separator for the current platform. | 30 | Pemisah file untuk platform saat ini. |
| 31 | 31 | ||
| 32 | **Signature:** | 32 | **Signature:** |
| 33 | ```lua | 33 | ```lua |
| @@ -36,11 +36,11 @@ dirsep: string | |||
| 36 | 36 | ||
| 37 | ### yue_compiled | 37 | ### yue_compiled |
| 38 | 38 | ||
| 39 | **Type:** Field. | 39 | **Tipe:** Field. |
| 40 | 40 | ||
| 41 | **Description:** | 41 | **Deskripsi:** |
| 42 | 42 | ||
| 43 | The compiled module code cache. | 43 | Cache kode modul yang telah dikompilasi. |
| 44 | 44 | ||
| 45 | **Signature:** | 45 | **Signature:** |
| 46 | ```lua | 46 | ```lua |
| @@ -49,11 +49,11 @@ yue_compiled: {string: string} | |||
| 49 | 49 | ||
| 50 | ### to_lua | 50 | ### to_lua |
| 51 | 51 | ||
| 52 | **Type:** Function. | 52 | **Tipe:** Function. |
| 53 | 53 | ||
| 54 | **Description:** | 54 | **Deskripsi:** |
| 55 | 55 | ||
| 56 | The YueScript compiling function. It compiles the YueScript code to Lua code. | 56 | Fungsi kompilasi YueScript. Mengompilasi kode YueScript menjadi kode Lua. |
| 57 | 57 | ||
| 58 | **Signature:** | 58 | **Signature:** |
| 59 | ```lua | 59 | ```lua |
| @@ -63,122 +63,122 @@ to_lua: function(code: string, config?: Config): | |||
| 63 | --[[globals]] {{string, integer, integer}} | nil | 63 | --[[globals]] {{string, integer, integer}} | nil |
| 64 | ``` | 64 | ``` |
| 65 | 65 | ||
| 66 | **Parameters:** | 66 | **Parameter:** |
| 67 | 67 | ||
| 68 | | Parameter | Type | Description | | 68 | | Parameter | Tipe | Deskripsi | |
| 69 | | --- | --- | --- | | 69 | | --- | --- | --- | |
| 70 | | code | string | The YueScript code. | | 70 | | code | string | Kode YueScript. | |
| 71 | | config | Config | [Optional] The compiler options. | | 71 | | config | Config | [Opsional] Opsi kompiler. | |
| 72 | 72 | ||
| 73 | **Returns:** | 73 | **Return:** |
| 74 | 74 | ||
| 75 | | Return Type | Description | | 75 | | Tipe Return | Deskripsi | |
| 76 | | --- | --- | | 76 | | --- | --- | |
| 77 | | string \| nil | The compiled Lua code, or nil if the compilation failed. | | 77 | | string \| nil | Kode Lua hasil kompilasi, atau nil jika kompilasi gagal. | |
| 78 | | string \| nil | The error message, or nil if the compilation succeeded. | | 78 | | string \| nil | Pesan error, atau nil jika kompilasi berhasil. | |
| 79 | | {{string, integer, integer}} \| nil | The global variables appearing in the code (with name, row and column), or nil if the compiler option `lint_global` is false. | | 79 | | {{string, integer, integer}} \| nil | Variabel global yang muncul dalam kode (dengan nama, baris, dan kolom), atau nil jika opsi kompiler `lint_global` bernilai false. | |
| 80 | 80 | ||
| 81 | ### file_exist | 81 | ### file_exist |
| 82 | 82 | ||
| 83 | **Type:** Function. | 83 | **Tipe:** Function. |
| 84 | 84 | ||
| 85 | **Description:** | 85 | **Deskripsi:** |
| 86 | 86 | ||
| 87 | The source file existence checking function. Can be overridden to customize the behavior. | 87 | Fungsi untuk memeriksa keberadaan file sumber. Dapat ditimpa untuk menyesuaikan perilaku. |
| 88 | 88 | ||
| 89 | **Signature:** | 89 | **Signature:** |
| 90 | ```lua | 90 | ```lua |
| 91 | file_exist: function(filename: string): boolean | 91 | file_exist: function(filename: string): boolean |
| 92 | ``` | 92 | ``` |
| 93 | 93 | ||
| 94 | **Parameters:** | 94 | **Parameter:** |
| 95 | 95 | ||
| 96 | | Parameter | Type | Description | | 96 | | Parameter | Tipe | Deskripsi | |
| 97 | | --- | --- | --- | | 97 | | --- | --- | --- | |
| 98 | | filename | string | The file name. | | 98 | | filename | string | Nama file. | |
| 99 | 99 | ||
| 100 | **Returns:** | 100 | **Return:** |
| 101 | 101 | ||
| 102 | | Return Type | Description | | 102 | | Tipe Return | Deskripsi | |
| 103 | | --- | --- | | 103 | | --- | --- | |
| 104 | | boolean | Whether the file exists. | | 104 | | boolean | Apakah file ada. | |
| 105 | 105 | ||
| 106 | ### read_file | 106 | ### read_file |
| 107 | 107 | ||
| 108 | **Type:** Function. | 108 | **Tipe:** Function. |
| 109 | 109 | ||
| 110 | **Description:** | 110 | **Deskripsi:** |
| 111 | 111 | ||
| 112 | The source file reading function. Can be overridden to customize the behavior. | 112 | Fungsi untuk membaca file sumber. Dapat ditimpa untuk menyesuaikan perilaku. |
| 113 | 113 | ||
| 114 | **Signature:** | 114 | **Signature:** |
| 115 | ```lua | 115 | ```lua |
| 116 | read_file: function(filename: string): string | 116 | read_file: function(filename: string): string |
| 117 | ``` | 117 | ``` |
| 118 | 118 | ||
| 119 | **Parameters:** | 119 | **Parameter:** |
| 120 | 120 | ||
| 121 | | Parameter | Type | Description | | 121 | | Parameter | Tipe | Deskripsi | |
| 122 | | --- | --- | --- | | 122 | | --- | --- | --- | |
| 123 | | filename | string | The file name. | | 123 | | filename | string | Nama file. | |
| 124 | 124 | ||
| 125 | **Returns:** | 125 | **Return:** |
| 126 | 126 | ||
| 127 | | Return Type | Description | | 127 | | Tipe Return | Deskripsi | |
| 128 | | --- | --- | | 128 | | --- | --- | |
| 129 | | string | The file content. | | 129 | | string | Isi file. | |
| 130 | 130 | ||
| 131 | ### insert_loader | 131 | ### insert_loader |
| 132 | 132 | ||
| 133 | **Type:** Function. | 133 | **Tipe:** Function. |
| 134 | 134 | ||
| 135 | **Description:** | 135 | **Deskripsi:** |
| 136 | 136 | ||
| 137 | Insert the YueScript loader to the package loaders (searchers). | 137 | Menyisipkan loader YueScript ke package loaders (searchers). |
| 138 | 138 | ||
| 139 | **Signature:** | 139 | **Signature:** |
| 140 | ```lua | 140 | ```lua |
| 141 | insert_loader: function(pos?: integer): boolean | 141 | insert_loader: function(pos?: integer): boolean |
| 142 | ``` | 142 | ``` |
| 143 | 143 | ||
| 144 | **Parameters:** | 144 | **Parameter:** |
| 145 | 145 | ||
| 146 | | Parameter | Type | Description | | 146 | | Parameter | Tipe | Deskripsi | |
| 147 | | --- | --- | --- | | 147 | | --- | --- | --- | |
| 148 | | pos | integer | [Optional] The position to insert the loader. Default is 3. | | 148 | | pos | integer | [Opsional] Posisi untuk menyisipkan loader. Default adalah 3. | |
| 149 | 149 | ||
| 150 | **Returns:** | 150 | **Return:** |
| 151 | 151 | ||
| 152 | | Return Type | Description | | 152 | | Tipe Return | Deskripsi | |
| 153 | | --- | --- | | 153 | | --- | --- | |
| 154 | | boolean | Whether the loader is inserted successfully. It will fail if the loader is already inserted. | | 154 | | boolean | Apakah loader berhasil disisipkan. Akan gagal jika loader sudah disisipkan. | |
| 155 | 155 | ||
| 156 | ### remove_loader | 156 | ### remove_loader |
| 157 | 157 | ||
| 158 | **Type:** Function. | 158 | **Tipe:** Function. |
| 159 | 159 | ||
| 160 | **Description:** | 160 | **Deskripsi:** |
| 161 | 161 | ||
| 162 | Remove the YueScript loader from the package loaders (searchers). | 162 | Menghapus loader YueScript dari package loaders (searchers). |
| 163 | 163 | ||
| 164 | **Signature:** | 164 | **Signature:** |
| 165 | ```lua | 165 | ```lua |
| 166 | remove_loader: function(): boolean | 166 | remove_loader: function(): boolean |
| 167 | ``` | 167 | ``` |
| 168 | 168 | ||
| 169 | **Returns:** | 169 | **Return:** |
| 170 | 170 | ||
| 171 | | Return Type | Description | | 171 | | Tipe Return | Deskripsi | |
| 172 | | --- | --- | | 172 | | --- | --- | |
| 173 | | boolean | Whether the loader is removed successfully. It will fail if the loader is not inserted. | | 173 | | boolean | Apakah loader berhasil dihapus. Akan gagal jika loader belum disisipkan. | |
| 174 | 174 | ||
| 175 | ### loadstring | 175 | ### loadstring |
| 176 | 176 | ||
| 177 | **Type:** Function. | 177 | **Tipe:** Function. |
| 178 | 178 | ||
| 179 | **Description:** | 179 | **Deskripsi:** |
| 180 | 180 | ||
| 181 | Loads YueScript code from a string into a function. | 181 | Memuat kode YueScript dari string menjadi fungsi. |
| 182 | 182 | ||
| 183 | **Signature:** | 183 | **Signature:** |
| 184 | ```lua | 184 | ```lua |
| @@ -187,29 +187,29 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf | |||
| 187 | --[[error]] string | nil | 187 | --[[error]] string | nil |
| 188 | ``` | 188 | ``` |
| 189 | 189 | ||
| 190 | **Parameters:** | 190 | **Parameter:** |
| 191 | 191 | ||
| 192 | | Parameter | Type | Description | | 192 | | Parameter | Tipe | Deskripsi | |
| 193 | | --- | --- | --- | | 193 | | --- | --- | --- | |
| 194 | | input | string | The YueScript code. | | 194 | | input | string | Kode YueScript. | |
| 195 | | chunkname | string | The name of the code chunk. | | 195 | | chunkname | string | Nama chunk kode. | |
| 196 | | env | table | The environment table. | | 196 | | env | table | Tabel environment. | |
| 197 | | config | Config | [Optional] The compiler options. | | 197 | | config | Config | [Opsional] Opsi kompiler. | |
| 198 | 198 | ||
| 199 | **Returns:** | 199 | **Return:** |
| 200 | 200 | ||
| 201 | | Return Type | Description | | 201 | | Tipe Return | Deskripsi | |
| 202 | | --- | --- | | 202 | | --- | --- | |
| 203 | | function \| nil | The loaded function, or nil if the loading failed. | | 203 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 204 | | string \| nil | The error message, or nil if the loading succeeded. | | 204 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 205 | 205 | ||
| 206 | ### loadstring | 206 | ### loadstring |
| 207 | 207 | ||
| 208 | **Type:** Function. | 208 | **Tipe:** Function. |
| 209 | 209 | ||
| 210 | **Description:** | 210 | **Deskripsi:** |
| 211 | 211 | ||
| 212 | Loads YueScript code from a string into a function. | 212 | Memuat kode YueScript dari string menjadi fungsi. |
| 213 | 213 | ||
| 214 | **Signature:** | 214 | **Signature:** |
| 215 | ```lua | 215 | ```lua |
| @@ -218,28 +218,28 @@ loadstring: function(input: string, chunkname: string, config?: Config): | |||
| 218 | --[[error]] string | nil | 218 | --[[error]] string | nil |
| 219 | ``` | 219 | ``` |
| 220 | 220 | ||
| 221 | **Parameters:** | 221 | **Parameter:** |
| 222 | 222 | ||
| 223 | | Parameter | Type | Description | | 223 | | Parameter | Tipe | Deskripsi | |
| 224 | | --- | --- | --- | | 224 | | --- | --- | --- | |
| 225 | | input | string | The YueScript code. | | 225 | | input | string | Kode YueScript. | |
| 226 | | chunkname | string | The name of the code chunk. | | 226 | | chunkname | string | Nama chunk kode. | |
| 227 | | config | Config | [Optional] The compiler options. | | 227 | | config | Config | [Opsional] Opsi kompiler. | |
| 228 | 228 | ||
| 229 | **Returns:** | 229 | **Return:** |
| 230 | 230 | ||
| 231 | | Return Type | Description | | 231 | | Tipe Return | Deskripsi | |
| 232 | | --- | --- | | 232 | | --- | --- | |
| 233 | | function \| nil | The loaded function, or nil if the loading failed. | | 233 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 234 | | string \| nil | The error message, or nil if the loading succeeded. | | 234 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 235 | 235 | ||
| 236 | ### loadstring | 236 | ### loadstring |
| 237 | 237 | ||
| 238 | **Type:** Function. | 238 | **Tipe:** Function. |
| 239 | 239 | ||
| 240 | **Description:** | 240 | **Deskripsi:** |
| 241 | 241 | ||
| 242 | Loads YueScript code from a string into a function. | 242 | Memuat kode YueScript dari string menjadi fungsi. |
| 243 | 243 | ||
| 244 | **Signature:** | 244 | **Signature:** |
| 245 | ```lua | 245 | ```lua |
| @@ -248,27 +248,27 @@ loadstring: function(input: string, config?: Config): | |||
| 248 | --[[error]] string | nil | 248 | --[[error]] string | nil |
| 249 | ``` | 249 | ``` |
| 250 | 250 | ||
| 251 | **Parameters:** | 251 | **Parameter:** |
| 252 | 252 | ||
| 253 | | Parameter | Type | Description | | 253 | | Parameter | Tipe | Deskripsi | |
| 254 | | --- | --- | --- | | 254 | | --- | --- | --- | |
| 255 | | input | string | The YueScript code. | | 255 | | input | string | Kode YueScript. | |
| 256 | | config | Config | [Optional] The compiler options. | | 256 | | config | Config | [Opsional] Opsi kompiler. | |
| 257 | 257 | ||
| 258 | **Returns:** | 258 | **Return:** |
| 259 | 259 | ||
| 260 | | Return Type | Description | | 260 | | Tipe Return | Deskripsi | |
| 261 | | --- | --- | | 261 | | --- | --- | |
| 262 | | function \| nil | The loaded function, or nil if the loading failed. | | 262 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 263 | | string \| nil | The error message, or nil if the loading succeeded. | | 263 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 264 | 264 | ||
| 265 | ### loadfile | 265 | ### loadfile |
| 266 | 266 | ||
| 267 | **Type:** Function. | 267 | **Tipe:** Function. |
| 268 | 268 | ||
| 269 | **Description:** | 269 | **Deskripsi:** |
| 270 | 270 | ||
| 271 | Loads YueScript code from a file into a function. | 271 | Memuat kode YueScript dari file menjadi fungsi. |
| 272 | 272 | ||
| 273 | **Signature:** | 273 | **Signature:** |
| 274 | ```lua | 274 | ```lua |
| @@ -277,28 +277,28 @@ loadfile: function(filename: string, env: table, config?: Config): | |||
| 277 | string | nil | 277 | string | nil |
| 278 | ``` | 278 | ``` |
| 279 | 279 | ||
| 280 | **Parameters:** | 280 | **Parameter:** |
| 281 | 281 | ||
| 282 | | Parameter | Type | Description | | 282 | | Parameter | Tipe | Deskripsi | |
| 283 | | --- | --- | --- | | 283 | | --- | --- | --- | |
| 284 | | filename | string | The file name. | | 284 | | filename | string | Nama file. | |
| 285 | | env | table | The environment table. | | 285 | | env | table | Tabel environment. | |
| 286 | | config | Config | [Optional] The compiler options. | | 286 | | config | Config | [Opsional] Opsi kompiler. | |
| 287 | 287 | ||
| 288 | **Returns:** | 288 | **Return:** |
| 289 | 289 | ||
| 290 | | Return Type | Description | | 290 | | Tipe Return | Deskripsi | |
| 291 | | --- | --- | | 291 | | --- | --- | |
| 292 | | function \| nil | The loaded function, or nil if the loading failed. | | 292 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 293 | | string \| nil | The error message, or nil if the loading succeeded. | | 293 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 294 | 294 | ||
| 295 | ### loadfile | 295 | ### loadfile |
| 296 | 296 | ||
| 297 | **Type:** Function. | 297 | **Tipe:** Function. |
| 298 | 298 | ||
| 299 | **Description:** | 299 | **Deskripsi:** |
| 300 | 300 | ||
| 301 | Loads YueScript code from a file into a function. | 301 | Memuat kode YueScript dari file menjadi fungsi. |
| 302 | 302 | ||
| 303 | **Signature:** | 303 | **Signature:** |
| 304 | ```lua | 304 | ```lua |
| @@ -307,178 +307,178 @@ loadfile: function(filename: string, config?: Config): | |||
| 307 | string | nil | 307 | string | nil |
| 308 | ``` | 308 | ``` |
| 309 | 309 | ||
| 310 | **Parameters:** | 310 | **Parameter:** |
| 311 | 311 | ||
| 312 | | Parameter | Type | Description | | 312 | | Parameter | Tipe | Deskripsi | |
| 313 | | --- | --- | --- | | 313 | | --- | --- | --- | |
| 314 | | filename | string | The file name. | | 314 | | filename | string | Nama file. | |
| 315 | | config | Config | [Optional] The compiler options. | | 315 | | config | Config | [Opsional] Opsi kompiler. | |
| 316 | 316 | ||
| 317 | **Returns:** | 317 | **Return:** |
| 318 | 318 | ||
| 319 | | Return Type | Description | | 319 | | Tipe Return | Deskripsi | |
| 320 | | --- | --- | | 320 | | --- | --- | |
| 321 | | function \| nil | The loaded function, or nil if the loading failed. | | 321 | | function \| nil | Fungsi yang dimuat, atau nil jika pemuatan gagal. | |
| 322 | | string \| nil | The error message, or nil if the loading succeeded. | | 322 | | string \| nil | Pesan error, atau nil jika pemuatan berhasil. | |
| 323 | 323 | ||
| 324 | ### dofile | 324 | ### dofile |
| 325 | 325 | ||
| 326 | **Type:** Function. | 326 | **Tipe:** Function. |
| 327 | 327 | ||
| 328 | **Description:** | 328 | **Deskripsi:** |
| 329 | 329 | ||
| 330 | Loads YueScript code from a file into a function and executes it. | 330 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. |
| 331 | 331 | ||
| 332 | **Signature:** | 332 | **Signature:** |
| 333 | ```lua | 333 | ```lua |
| 334 | dofile: function(filename: string, env: table, config?: Config): any... | 334 | dofile: function(filename: string, env: table, config?: Config): any... |
| 335 | ``` | 335 | ``` |
| 336 | 336 | ||
| 337 | **Parameters:** | 337 | **Parameter:** |
| 338 | 338 | ||
| 339 | | Parameter | Type | Description | | 339 | | Parameter | Tipe | Deskripsi | |
| 340 | | --- | --- | --- | | 340 | | --- | --- | --- | |
| 341 | | filename | string | The file name. | | 341 | | filename | string | Nama file. | |
| 342 | | env | table | The environment table. | | 342 | | env | table | Tabel environment. | |
| 343 | | config | Config | [Optional] The compiler options. | | 343 | | config | Config | [Opsional] Opsi kompiler. | |
| 344 | 344 | ||
| 345 | **Returns:** | 345 | **Return:** |
| 346 | 346 | ||
| 347 | | Return Type | Description | | 347 | | Tipe Return | Deskripsi | |
| 348 | | --- | --- | | 348 | | --- | --- | |
| 349 | | any... | The return values of the loaded function. | | 349 | | any... | Nilai return dari fungsi yang dimuat. | |
| 350 | 350 | ||
| 351 | ### dofile | 351 | ### dofile |
| 352 | 352 | ||
| 353 | **Type:** Function. | 353 | **Tipe:** Function. |
| 354 | 354 | ||
| 355 | **Description:** | 355 | **Deskripsi:** |
| 356 | 356 | ||
| 357 | Loads YueScript code from a file into a function and executes it. | 357 | Memuat kode YueScript dari file menjadi fungsi dan mengeksekusinya. |
| 358 | 358 | ||
| 359 | **Signature:** | 359 | **Signature:** |
| 360 | ```lua | 360 | ```lua |
| 361 | dofile: function(filename: string, config?: Config): any... | 361 | dofile: function(filename: string, config?: Config): any... |
| 362 | ``` | 362 | ``` |
| 363 | 363 | ||
| 364 | **Parameters:** | 364 | **Parameter:** |
| 365 | 365 | ||
| 366 | | Parameter | Type | Description | | 366 | | Parameter | Tipe | Deskripsi | |
| 367 | | --- | --- | --- | | 367 | | --- | --- | --- | |
| 368 | | filename | string | The file name. | | 368 | | filename | string | Nama file. | |
| 369 | | config | Config | [Optional] The compiler options. | | 369 | | config | Config | [Opsional] Opsi kompiler. | |
| 370 | 370 | ||
| 371 | **Returns:** | 371 | **Return:** |
| 372 | 372 | ||
| 373 | | Return Type | Description | | 373 | | Tipe Return | Deskripsi | |
| 374 | | --- | --- | | 374 | | --- | --- | |
| 375 | | any... | The return values of the loaded function. | | 375 | | any... | Nilai return dari fungsi yang dimuat. | |
| 376 | 376 | ||
| 377 | ### find_modulepath | 377 | ### find_modulepath |
| 378 | 378 | ||
| 379 | **Type:** Function. | 379 | **Tipe:** Function. |
| 380 | 380 | ||
| 381 | **Description:** | 381 | **Deskripsi:** |
| 382 | 382 | ||
| 383 | Resolves the YueScript module name to the file path. | 383 | Menguraikan nama modul YueScript menjadi path file. |
| 384 | 384 | ||
| 385 | **Signature:** | 385 | **Signature:** |
| 386 | ```lua | 386 | ```lua |
| 387 | find_modulepath: function(name: string): string | 387 | find_modulepath: function(name: string): string |
| 388 | ``` | 388 | ``` |
| 389 | 389 | ||
| 390 | **Parameters:** | 390 | **Parameter:** |
| 391 | 391 | ||
| 392 | | Parameter | Type | Description | | 392 | | Parameter | Tipe | Deskripsi | |
| 393 | | --- | --- | --- | | 393 | | --- | --- | --- | |
| 394 | | name | string | The module name. | | 394 | | name | string | Nama modul. | |
| 395 | 395 | ||
| 396 | **Returns:** | 396 | **Return:** |
| 397 | 397 | ||
| 398 | | Return Type | Description | | 398 | | Tipe Return | Deskripsi | |
| 399 | | --- | --- | | 399 | | --- | --- | |
| 400 | | string | The file path. | | 400 | | string | Path file. | |
| 401 | 401 | ||
| 402 | ### pcall | 402 | ### pcall |
| 403 | 403 | ||
| 404 | **Type:** Function. | 404 | **Tipe:** Function. |
| 405 | 405 | ||
| 406 | **Description:** | 406 | **Deskripsi:** |
| 407 | 407 | ||
| 408 | Calls a function in protected mode. | 408 | Memanggil fungsi dalam mode terlindungi. |
| 409 | Catches any errors and returns a status code and results or error object. | 409 | Menangkap error apa pun dan mengembalikan kode status beserta hasil atau objek error. |
| 410 | Rewrites the error line number to the original line number in the YueScript code when errors occur. | 410 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat error terjadi. |
| 411 | 411 | ||
| 412 | **Signature:** | 412 | **Signature:** |
| 413 | ```lua | 413 | ```lua |
| 414 | pcall: function(f: function, ...: any): boolean, any... | 414 | pcall: function(f: function, ...: any): boolean, any... |
| 415 | ``` | 415 | ``` |
| 416 | 416 | ||
| 417 | **Parameters:** | 417 | **Parameter:** |
| 418 | 418 | ||
| 419 | | Parameter | Type | Description | | 419 | | Parameter | Tipe | Deskripsi | |
| 420 | | --- | --- | --- | | 420 | | --- | --- | --- | |
| 421 | | f | function | The function to call. | | 421 | | f | function | Fungsi yang akan dipanggil. | |
| 422 | | ... | any | Arguments to pass to the function. | | 422 | | ... | any | Argumen yang diteruskan ke fungsi. | |
| 423 | 423 | ||
| 424 | **Returns:** | 424 | **Return:** |
| 425 | 425 | ||
| 426 | | Return Type | Description | | 426 | | Tipe Return | Deskripsi | |
| 427 | | --- | --- | | 427 | | --- | --- | |
| 428 | | boolean, ... | Status code and function results or error object. | | 428 | | boolean, ... | Kode status dan hasil fungsi atau objek error. | |
| 429 | 429 | ||
| 430 | ### require | 430 | ### require |
| 431 | 431 | ||
| 432 | **Type:** Function. | 432 | **Tipe:** Function. |
| 433 | 433 | ||
| 434 | **Description:** | 434 | **Deskripsi:** |
| 435 | 435 | ||
| 436 | Loads a given module. Can be either a Lua module or a YueScript module. | 436 | Memuat modul tertentu. Bisa berupa modul Lua atau modul YueScript. |
| 437 | Rewrites the error line number to the original line number in the YueScript code if the module is a YueScript module and loading fails. | 437 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript jika modul adalah modul YueScript dan pemuatan gagal. |
| 438 | 438 | ||
| 439 | **Signature:** | 439 | **Signature:** |
| 440 | ```lua | 440 | ```lua |
| 441 | require: function(name: string): any... | 441 | require: function(name: string): any... |
| 442 | ``` | 442 | ``` |
| 443 | 443 | ||
| 444 | **Parameters:** | 444 | **Parameter:** |
| 445 | 445 | ||
| 446 | | Parameter | Type | Description | | 446 | | Parameter | Tipe | Deskripsi | |
| 447 | | --- | --- | --- | | 447 | | --- | --- | --- | |
| 448 | | modname | string | The name of the module to load. | | 448 | | modname | string | Nama modul yang akan dimuat. | |
| 449 | 449 | ||
| 450 | **Returns:** | 450 | **Return:** |
| 451 | 451 | ||
| 452 | | Return Type | Description | | 452 | | Tipe Return | Deskripsi | |
| 453 | | --- | --- | | 453 | | --- | --- | |
| 454 | | any | The value stored at package.loaded[modname] if the module is already loaded.Otherwise, tries to find a loader and returns the final value of package.loaded[modname] and a loader data as a second result. | | 454 | | any | Nilai yang disimpan di package.loaded[modname] jika modul sudah dimuat. Jika belum, mencoba mencari loader dan mengembalikan nilai akhir package.loaded[modname] serta data loader sebagai hasil kedua. | |
| 455 | 455 | ||
| 456 | ### p | 456 | ### p |
| 457 | 457 | ||
| 458 | **Type:** Function. | 458 | **Tipe:** Function. |
| 459 | 459 | ||
| 460 | **Description:** | 460 | **Deskripsi:** |
| 461 | 461 | ||
| 462 | Inspects the structures of the passed values and prints string representations. | 462 | Memeriksa struktur nilai yang diteruskan dan mencetak representasi string. |
| 463 | 463 | ||
| 464 | **Signature:** | 464 | **Signature:** |
| 465 | ```lua | 465 | ```lua |
| 466 | p: function(...: any) | 466 | p: function(...: any) |
| 467 | ``` | 467 | ``` |
| 468 | 468 | ||
| 469 | **Parameters:** | 469 | **Parameter:** |
| 470 | 470 | ||
| 471 | | Parameter | Type | Description | | 471 | | Parameter | Tipe | Deskripsi | |
| 472 | | --- | --- | --- | | 472 | | --- | --- | --- | |
| 473 | | ... | any | The values to inspect. | | 473 | | ... | any | Nilai yang akan diperiksa. | |
| 474 | 474 | ||
| 475 | ### options | 475 | ### options |
| 476 | 476 | ||
| 477 | **Type:** Field. | 477 | **Tipe:** Field. |
| 478 | 478 | ||
| 479 | **Description:** | 479 | **Deskripsi:** |
| 480 | 480 | ||
| 481 | The current compiler options. | 481 | Opsi kompiler saat ini. |
| 482 | 482 | ||
| 483 | **Signature:** | 483 | **Signature:** |
| 484 | ```lua | 484 | ```lua |
| @@ -487,62 +487,62 @@ options: Config.Options | |||
| 487 | 487 | ||
| 488 | ### traceback | 488 | ### traceback |
| 489 | 489 | ||
| 490 | **Type:** Function. | 490 | **Tipe:** Function. |
| 491 | 491 | ||
| 492 | **Description:** | 492 | **Deskripsi:** |
| 493 | 493 | ||
| 494 | The traceback function that rewrites the stack trace line numbers to the original line numbers in the YueScript code. | 494 | Fungsi traceback yang menulis ulang nomor baris stack trace ke nomor baris asli di kode YueScript. |
| 495 | 495 | ||
| 496 | **Signature:** | 496 | **Signature:** |
| 497 | ```lua | 497 | ```lua |
| 498 | traceback: function(message: string): string | 498 | traceback: function(message: string): string |
| 499 | ``` | 499 | ``` |
| 500 | 500 | ||
| 501 | **Parameters:** | 501 | **Parameter:** |
| 502 | 502 | ||
| 503 | | Parameter | Type | Description | | 503 | | Parameter | Tipe | Deskripsi | |
| 504 | | --- | --- | --- | | 504 | | --- | --- | --- | |
| 505 | | message | string | The traceback message. | | 505 | | message | string | Pesan traceback. | |
| 506 | 506 | ||
| 507 | **Returns:** | 507 | **Return:** |
| 508 | 508 | ||
| 509 | | Return Type | Description | | 509 | | Tipe Return | Deskripsi | |
| 510 | | --- | --- | | 510 | | --- | --- | |
| 511 | | string | The rewritten traceback message. | | 511 | | string | Pesan traceback yang telah ditulis ulang. | |
| 512 | 512 | ||
| 513 | ### is_ast | 513 | ### is_ast |
| 514 | 514 | ||
| 515 | **Type:** Function. | 515 | **Tipe:** Function. |
| 516 | 516 | ||
| 517 | **Description:** | 517 | **Deskripsi:** |
| 518 | 518 | ||
| 519 | Checks whether the code matches the specified AST. | 519 | Memeriksa apakah kode cocok dengan AST yang ditentukan. |
| 520 | 520 | ||
| 521 | **Signature:** | 521 | **Signature:** |
| 522 | ```lua | 522 | ```lua |
| 523 | is_ast: function(astName: string, code: string): boolean | 523 | is_ast: function(astName: string, code: string): boolean |
| 524 | ``` | 524 | ``` |
| 525 | 525 | ||
| 526 | **Parameters:** | 526 | **Parameter:** |
| 527 | 527 | ||
| 528 | | Parameter | Type | Description | | 528 | | Parameter | Tipe | Deskripsi | |
| 529 | | --- | --- | --- | | 529 | | --- | --- | --- | |
| 530 | | astName | string | The AST name. | | 530 | | astName | string | Nama AST. | |
| 531 | | code | string | The code. | | 531 | | code | string | Kode. | |
| 532 | 532 | ||
| 533 | **Returns:** | 533 | **Return:** |
| 534 | 534 | ||
| 535 | | Return Type | Description | | 535 | | Tipe Return | Deskripsi | |
| 536 | | --- | --- | | 536 | | --- | --- | |
| 537 | | boolean | Whether the code matches the AST. | | 537 | | boolean | Apakah kode cocok dengan AST. | |
| 538 | 538 | ||
| 539 | ### AST | 539 | ### AST |
| 540 | 540 | ||
| 541 | **Type:** Field. | 541 | **Tipe:** Field. |
| 542 | 542 | ||
| 543 | **Description:** | 543 | **Deskripsi:** |
| 544 | 544 | ||
| 545 | The AST type definition with name, row, column and sub nodes. | 545 | Definisi tipe AST dengan nama, baris, kolom, dan sub-node. |
| 546 | 546 | ||
| 547 | **Signature:** | 547 | **Signature:** |
| 548 | ```lua | 548 | ```lua |
| @@ -551,11 +551,11 @@ type AST = {string, integer, integer, any} | |||
| 551 | 551 | ||
| 552 | ### to_ast | 552 | ### to_ast |
| 553 | 553 | ||
| 554 | **Type:** Function. | 554 | **Tipe:** Function. |
| 555 | 555 | ||
| 556 | **Description:** | 556 | **Deskripsi:** |
| 557 | 557 | ||
| 558 | Converts the code to the AST. | 558 | Mengonversi kode menjadi AST. |
| 559 | 559 | ||
| 560 | **Signature:** | 560 | **Signature:** |
| 561 | ```lua | 561 | ```lua |
| @@ -564,88 +564,88 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC | |||
| 564 | --[[error]] nil | string | 564 | --[[error]] nil | string |
| 565 | ``` | 565 | ``` |
| 566 | 566 | ||
| 567 | **Parameters:** | 567 | **Parameter:** |
| 568 | 568 | ||
| 569 | | Parameter | Type | Description | | 569 | | Parameter | Tipe | Deskripsi | |
| 570 | | --- | --- | --- | | 570 | | --- | --- | --- | |
| 571 | | code | string | The code. | | 571 | | code | string | Kode. | |
| 572 | | flattenLevel | integer | [Optional] The flatten level. Higher level means more flattening. Default is 0. Maximum is 2. | | 572 | | flattenLevel | integer | [Opsional] Tingkat perataan. Semakin tinggi berarti semakin rata. Default 0. Maksimum 2. | |
| 573 | | astName | string | [Optional] The AST name. Default is "File". | | 573 | | astName | string | [Opsional] Nama AST. Default "File". | |
| 574 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is false. | | 574 | | reserveComment | boolean | [Opsional] Apakah akan mempertahankan komentar asli. Default false. | |
| 575 | 575 | ||
| 576 | **Returns:** | 576 | **Return:** |
| 577 | 577 | ||
| 578 | | Return Type | Description | | 578 | | Tipe Return | Deskripsi | |
| 579 | | --- | --- | | 579 | | --- | --- | |
| 580 | | AST \| nil | The AST, or nil if the conversion failed. | | 580 | | AST \| nil | AST, atau nil jika konversi gagal. | |
| 581 | | string \| nil | The error message, or nil if the conversion succeeded. | | 581 | | string \| nil | Pesan error, atau nil jika konversi berhasil. | |
| 582 | 582 | ||
| 583 | ### format | 583 | ### format |
| 584 | 584 | ||
| 585 | **Type:** Function. | 585 | **Tipe:** Function. |
| 586 | 586 | ||
| 587 | **Description:** | 587 | **Deskripsi:** |
| 588 | 588 | ||
| 589 | Formats the YueScript code. | 589 | Memformat kode YueScript. |
| 590 | 590 | ||
| 591 | **Signature:** | 591 | **Signature:** |
| 592 | ```lua | 592 | ```lua |
| 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string | 593 | format: function(code: string, tabSize?: number, reserveComment?: boolean): string |
| 594 | ``` | 594 | ``` |
| 595 | 595 | ||
| 596 | **Parameters:** | 596 | **Parameter:** |
| 597 | 597 | ||
| 598 | | Parameter | Type | Description | | 598 | | Parameter | Tipe | Deskripsi | |
| 599 | | --- | --- | --- | | 599 | | --- | --- | --- | |
| 600 | | code | string | The code. | | 600 | | code | string | Kode. | |
| 601 | | tabSize | integer | [Optional] The tab size. Default is 4. | | 601 | | tabSize | integer | [Opsional] Ukuran tab. Default 4. | |
| 602 | | reserveComment | boolean | [Optional] Whether to reserve the original comments. Default is true. | | 602 | | reserveComment | boolean | [Opsional] Apakah mempertahankan komentar asli. Default true. | |
| 603 | 603 | ||
| 604 | **Returns:** | 604 | **Return:** |
| 605 | 605 | ||
| 606 | | Return Type | Description | | 606 | | Tipe Return | Deskripsi | |
| 607 | | --- | --- | | 607 | | --- | --- | |
| 608 | | string | The formatted code. | | 608 | | string | Kode yang telah diformat. | |
| 609 | 609 | ||
| 610 | ### __call | 610 | ### __call |
| 611 | 611 | ||
| 612 | **Type:** Metamethod. | 612 | **Tipe:** Metamethod. |
| 613 | 613 | ||
| 614 | **Description:** | 614 | **Deskripsi:** |
| 615 | 615 | ||
| 616 | Requires the YueScript module. | 616 | Me-require modul YueScript. |
| 617 | Rewrites the error line number to the original line number in the YueScript code when loading fails. | 617 | Menulis ulang nomor baris error ke nomor baris asli di kode YueScript saat pemuatan gagal. |
| 618 | 618 | ||
| 619 | **Signature:** | 619 | **Signature:** |
| 620 | ```lua | 620 | ```lua |
| 621 | metamethod __call: function(self: yue, module: string): any... | 621 | metamethod __call: function(self: yue, module: string): any... |
| 622 | ``` | 622 | ``` |
| 623 | 623 | ||
| 624 | **Parameters:** | 624 | **Parameter:** |
| 625 | 625 | ||
| 626 | | Parameter | Type | Description | | 626 | | Parameter | Tipe | Deskripsi | |
| 627 | | --- | --- | --- | | 627 | | --- | --- | --- | |
| 628 | | module | string | The module name. | | 628 | | module | string | Nama modul. | |
| 629 | 629 | ||
| 630 | **Returns:** | 630 | **Return:** |
| 631 | 631 | ||
| 632 | | Return Type | Description | | 632 | | Tipe Return | Deskripsi | |
| 633 | | --- | --- | | 633 | | --- | --- | |
| 634 | | any | The module value. | | 634 | | any | Nilai modul. | |
| 635 | 635 | ||
| 636 | ## Config | 636 | ## Config |
| 637 | 637 | ||
| 638 | **Description:** | 638 | **Deskripsi:** |
| 639 | 639 | ||
| 640 | The compiler compile options. | 640 | Opsi kompilasi kompiler. |
| 641 | 641 | ||
| 642 | ### lint_global | 642 | ### lint_global |
| 643 | 643 | ||
| 644 | **Type:** Field. | 644 | **Tipe:** Field. |
| 645 | 645 | ||
| 646 | **Description:** | 646 | **Deskripsi:** |
| 647 | 647 | ||
| 648 | Whether the compiler should collect the global variables appearing in the code. | 648 | Apakah kompiler harus mengumpulkan variabel global yang muncul dalam kode. |
| 649 | 649 | ||
| 650 | **Signature:** | 650 | **Signature:** |
| 651 | ```lua | 651 | ```lua |
| @@ -654,11 +654,11 @@ lint_global: boolean | |||
| 654 | 654 | ||
| 655 | ### implicit_return_root | 655 | ### implicit_return_root |
| 656 | 656 | ||
| 657 | **Type:** Field. | 657 | **Tipe:** Field. |
| 658 | 658 | ||
| 659 | **Description:** | 659 | **Deskripsi:** |
| 660 | 660 | ||
| 661 | Whether the compiler should do an implicit return for the root code block. | 661 | Apakah kompiler harus melakukan return implisit untuk blok kode root. |
| 662 | 662 | ||
| 663 | **Signature:** | 663 | **Signature:** |
| 664 | ```lua | 664 | ```lua |
| @@ -667,11 +667,11 @@ implicit_return_root: boolean | |||
| 667 | 667 | ||
| 668 | ### reserve_line_number | 668 | ### reserve_line_number |
| 669 | 669 | ||
| 670 | **Type:** Field. | 670 | **Tipe:** Field. |
| 671 | 671 | ||
| 672 | **Description:** | 672 | **Deskripsi:** |
| 673 | 673 | ||
| 674 | Whether the compiler should reserve the original line number in the compiled code. | 674 | Apakah kompiler harus mempertahankan nomor baris asli di kode hasil kompilasi. |
| 675 | 675 | ||
| 676 | **Signature:** | 676 | **Signature:** |
| 677 | ```lua | 677 | ```lua |
| @@ -680,11 +680,11 @@ reserve_line_number: boolean | |||
| 680 | 680 | ||
| 681 | ### reserve_comment | 681 | ### reserve_comment |
| 682 | 682 | ||
| 683 | **Type:** Field. | 683 | **Tipe:** Field. |
| 684 | 684 | ||
| 685 | **Description:** | 685 | **Deskripsi:** |
| 686 | 686 | ||
| 687 | Whether the compiler should reserve the original comments in the compiled code. | 687 | Apakah kompiler harus mempertahankan komentar asli di kode hasil kompilasi. |
| 688 | 688 | ||
| 689 | **Signature:** | 689 | **Signature:** |
| 690 | ```lua | 690 | ```lua |
| @@ -693,11 +693,11 @@ reserve_comment: boolean | |||
| 693 | 693 | ||
| 694 | ### space_over_tab | 694 | ### space_over_tab |
| 695 | 695 | ||
| 696 | **Type:** Field. | 696 | **Tipe:** Field. |
| 697 | 697 | ||
| 698 | **Description:** | 698 | **Deskripsi:** |
| 699 | 699 | ||
| 700 | Whether the compiler should use the space character instead of the tab character in the compiled code. | 700 | Apakah kompiler harus menggunakan karakter spasi alih-alih tab di kode hasil kompilasi. |
| 701 | 701 | ||
| 702 | **Signature:** | 702 | **Signature:** |
| 703 | ```lua | 703 | ```lua |
| @@ -706,11 +706,11 @@ space_over_tab: boolean | |||
| 706 | 706 | ||
| 707 | ### same_module | 707 | ### same_module |
| 708 | 708 | ||
| 709 | **Type:** Field. | 709 | **Tipe:** Field. |
| 710 | 710 | ||
| 711 | **Description:** | 711 | **Deskripsi:** |
| 712 | 712 | ||
| 713 | Whether the compiler should treat the code to be compiled as the same currently being compiled module. For internal use only. | 713 | Apakah kompiler harus memperlakukan kode yang akan dikompilasi sebagai modul yang sama dengan modul yang sedang dikompilasi. Untuk penggunaan internal saja. |
| 714 | 714 | ||
| 715 | **Signature:** | 715 | **Signature:** |
| 716 | ```lua | 716 | ```lua |
| @@ -719,11 +719,11 @@ same_module: boolean | |||
| 719 | 719 | ||
| 720 | ### line_offset | 720 | ### line_offset |
| 721 | 721 | ||
| 722 | **Type:** Field. | 722 | **Tipe:** Field. |
| 723 | 723 | ||
| 724 | **Description:** | 724 | **Deskripsi:** |
| 725 | 725 | ||
| 726 | Whether the compiler error message should include the line number offset. For internal use only. | 726 | Apakah pesan error kompiler harus menyertakan offset nomor baris. Untuk penggunaan internal saja. |
| 727 | 727 | ||
| 728 | **Signature:** | 728 | **Signature:** |
| 729 | ```lua | 729 | ```lua |
| @@ -732,11 +732,11 @@ line_offset: integer | |||
| 732 | 732 | ||
| 733 | ### yue.Config.LuaTarget | 733 | ### yue.Config.LuaTarget |
| 734 | 734 | ||
| 735 | **Type:** Enumeration. | 735 | **Tipe:** Enumeration. |
| 736 | 736 | ||
| 737 | **Description:** | 737 | **Deskripsi:** |
| 738 | 738 | ||
| 739 | The target Lua version enumeration. | 739 | Enumerasi versi Lua target. |
| 740 | 740 | ||
| 741 | **Signature:** | 741 | **Signature:** |
| 742 | ```lua | 742 | ```lua |
| @@ -751,11 +751,11 @@ end | |||
| 751 | 751 | ||
| 752 | ### options | 752 | ### options |
| 753 | 753 | ||
| 754 | **Type:** Field. | 754 | **Tipe:** Field. |
| 755 | 755 | ||
| 756 | **Description:** | 756 | **Deskripsi:** |
| 757 | 757 | ||
| 758 | The extra options to be passed to the compilation function. | 758 | Opsi tambahan untuk diteruskan ke fungsi kompilasi. |
| 759 | 759 | ||
| 760 | **Signature:** | 760 | **Signature:** |
| 761 | ```lua | 761 | ```lua |
| @@ -764,17 +764,17 @@ options: Options | |||
| 764 | 764 | ||
| 765 | ## Options | 765 | ## Options |
| 766 | 766 | ||
| 767 | **Description:** | 767 | **Deskripsi:** |
| 768 | 768 | ||
| 769 | The extra compiler options definition. | 769 | Definisi opsi kompiler tambahan. |
| 770 | 770 | ||
| 771 | ### target | 771 | ### target |
| 772 | 772 | ||
| 773 | **Type:** Field. | 773 | **Tipe:** Field. |
| 774 | 774 | ||
| 775 | **Description:** | 775 | **Deskripsi:** |
| 776 | 776 | ||
| 777 | The target Lua version for the compilation. | 777 | Versi Lua target untuk kompilasi. |
| 778 | 778 | ||
| 779 | **Signature:** | 779 | **Signature:** |
| 780 | ```lua | 780 | ```lua |
| @@ -783,11 +783,11 @@ target: LuaTarget | |||
| 783 | 783 | ||
| 784 | ### path | 784 | ### path |
| 785 | 785 | ||
| 786 | **Type:** Field. | 786 | **Tipe:** Field. |
| 787 | 787 | ||
| 788 | **Description:** | 788 | **Deskripsi:** |
| 789 | 789 | ||
| 790 | The extra module search path. | 790 | Path pencarian modul tambahan. |
| 791 | 791 | ||
| 792 | **Signature:** | 792 | **Signature:** |
| 793 | ```lua | 793 | ```lua |
| @@ -796,11 +796,11 @@ path: string | |||
| 796 | 796 | ||
| 797 | ### dump_locals | 797 | ### dump_locals |
| 798 | 798 | ||
| 799 | **Type:** Field. | 799 | **Tipe:** Field. |
| 800 | 800 | ||
| 801 | **Description:** | 801 | **Deskripsi:** |
| 802 | 802 | ||
| 803 | Whether to dump the local variables in the traceback error message. Default is false. | 803 | Apakah akan menampilkan variabel local dalam pesan error traceback. Default false. |
| 804 | 804 | ||
| 805 | **Signature:** | 805 | **Signature:** |
| 806 | ```lua | 806 | ```lua |
| @@ -809,11 +809,11 @@ dump_locals: boolean | |||
| 809 | 809 | ||
| 810 | ### simplified | 810 | ### simplified |
| 811 | 811 | ||
| 812 | **Type:** Field. | 812 | **Tipe:** Field. |
| 813 | 813 | ||
| 814 | **Description:** | 814 | **Deskripsi:** |
| 815 | 815 | ||
| 816 | Whether to simplify the error message. Default is true. | 816 | Apakah akan menyederhanakan pesan error. Default true. |
| 817 | 817 | ||
| 818 | **Signature:** | 818 | **Signature:** |
| 819 | ```lua | 819 | ```lua |
diff --git a/doc/docs/id-id/index.md b/doc/docs/id-id/index.md index 016b688..c8b5fab 100644 --- a/doc/docs/id-id/index.md +++ b/doc/docs/id-id/index.md | |||
| @@ -2,22 +2,22 @@ | |||
| 2 | layout: home | 2 | layout: home |
| 3 | hero: | 3 | hero: |
| 4 | name: YueScript | 4 | name: YueScript |
| 5 | tagline: A language that compiles to Lua | 5 | tagline: Bahasa yang dikompilasi ke Lua |
| 6 | image: | 6 | image: |
| 7 | src: /image/yuescript.svg | 7 | src: /image/yuescript.svg |
| 8 | alt: YueScript | 8 | alt: YueScript |
| 9 | actions: | 9 | actions: |
| 10 | - theme: brand | 10 | - theme: brand |
| 11 | text: Quick Start → | 11 | text: Mulai Cepat → |
| 12 | link: /doc/ | 12 | link: /doc/ |
| 13 | features: | 13 | features: |
| 14 | - title: Familiar Lua workflows | 14 | - title: Alur kerja Lua yang familiar |
| 15 | details: Write concise syntax that compiles to readable Lua, with predictable output. | 15 | details: Tulis sintaks ringkas yang dikompilasi ke Lua yang mudah dibaca, dengan output yang dapat diprediksi. |
| 16 | - title: Modern language features | 16 | - title: Fitur bahasa modern |
| 17 | details: Pipe, pattern matching, slicing, and destructuring without giving up Lua interop. | 17 | details: Pipe, pattern matching, slicing, dan destrukturisasi tanpa mengorbankan interoperabilitas Lua. |
| 18 | - title: Rapid Iteration | 18 | - title: Iterasi Cepat |
| 19 | details: Any feedback is welcome to help accelerate the language development and evolution! | 19 | details: Setiap masukan sangat diterima untuk membantu mempercepat pengembangan dan evolusi bahasa! |
| 20 | footer: | 20 | footer: |
| 21 | message: MIT License. | 21 | message: Lisensi MIT. |
| 22 | copyright: Copyright © 2017-2026 Li Jin. All rights reserved. | 22 | copyright: Hak cipta © 2017-2026 Li Jin. Semua hak dilindungi. |
| 23 | --- | 23 | --- |
diff --git a/doc/docs/id-id/try/index.md b/doc/docs/id-id/try/index.md index 85a903b..c31dc1c 100755 --- a/doc/docs/id-id/try/index.md +++ b/doc/docs/id-id/try/index.md | |||
| @@ -4,9 +4,9 @@ prev: false | |||
| 4 | next: false | 4 | next: false |
| 5 | --- | 5 | --- |
| 6 | 6 | ||
| 7 | # YueScript Online Compiler | 7 | # Kompiler Online YueScript |
| 8 | --- | 8 | --- |
| 9 | 9 | ||
| 10 | Try YueScript in the browser with WASM. | 10 | Coba YueScript di browser dengan WASM. |
| 11 | 11 | ||
| 12 | <YueCompiler /> | 12 | <YueCompiler /> |
