rhai/doc/src/appendix/keywords.md

79 lines
5.6 KiB
Markdown
Raw Normal View History

2020-06-21 18:03:45 +02:00
Keywords List
=============
{{#include ../links.md}}
2020-10-03 10:25:58 +02:00
| Keyword | Description | Inactive under | Is function? | Overloadable |
| :-------------------: | ------------------------------------------- | :-------------: | :----------: | :----------: |
| `true` | boolean true literal | | no | |
| `false` | boolean false literal | | no | |
| `let` | variable declaration | | no | |
| `const` | constant declaration | | no | |
| `is_def_var` | is a variable declared? | | yes | yes |
| `is_shared` | is a value shared? | [`no_closure`] | yes | no |
| `if` | if statement | | no | |
| `else` | else block of if statement | | no | |
2020-11-13 11:32:18 +01:00
| `switch` | matching | | no | |
2020-11-20 15:23:37 +01:00
| `do` | looping | | no | |
| `while` | 1) while loop<br/>2) condition for do loop | | no | |
| `until` | do loop | | no | |
2020-10-03 10:25:58 +02:00
| `loop` | infinite loop | | no | |
| `for` | for loop | | no | |
| `in` | 1) containment test<br/>2) part of for loop | | no | |
| `continue` | continue a loop at the next iteration | | no | |
| `break` | break out of loop iteration | | no | |
| `return` | return value | | no | |
| `throw` | throw exception | | no | |
2020-10-20 17:16:03 +02:00
| `try` | trap exception | | no | |
| `catch` | catch exception | | no | |
2020-10-03 10:25:58 +02:00
| `import` | import module | [`no_module`] | no | |
| `export` | export variable | [`no_module`] | no | |
| `as` | alias for variable export | [`no_module`] | no | |
| `private` | mark function private | [`no_function`] | no | |
| `fn` (lower-case `f`) | function definition | [`no_function`] | no | |
| `Fn` (capital `F`) | create a [function pointer] | | yes | yes |
| `call` | call a [function pointer] | | yes | no |
| `curry` | curry a [function pointer] | | yes | no |
| `this` | reference to base object for method call | [`no_function`] | no | |
| `is_def_fn` | is a scripted function defined? | [`no_function`] | yes | yes |
| `type_of` | get type name of value | | yes | yes |
| `print` | print value | | yes | yes |
| `debug` | print value in debug format | | yes | yes |
| `eval` | evaluate script | | yes | yes |
2020-07-26 15:57:30 +02:00
Reserved Keywords
-----------------
| Keyword | Potential usage |
| --------- | --------------------- |
2020-09-24 05:17:39 +02:00
| `var` | variable declaration |
| `static` | variable declaration |
2020-11-21 08:44:17 +01:00
| `begin` | block scope |
| `end` | block scope |
2020-09-24 05:17:39 +02:00
| `shared` | share value |
| `each` | looping |
| `then` | control flow |
| `goto` | control flow |
| `exit` | control flow |
2020-11-20 15:23:37 +01:00
| `unless` | control flow |
2020-09-24 05:17:39 +02:00
| `match` | matching |
| `case` | matching |
| `public` | function/field access |
| `new` | constructor |
| `use` | import namespace |
| `with` | scope |
| `module` | module |
| `package` | package |
2020-10-22 06:26:44 +02:00
| `thread` | threading |
2020-09-24 05:17:39 +02:00
| `spawn` | threading |
| `go` | threading |
| `await` | async |
| `async` | async |
| `sync` | async |
| `yield` | async |
| `default` | special value |
| `void` | special value |
| `null` | special value |
| `nil` | special value |