Reserve begin/end.
This commit is contained in:
@@ -97,7 +97,7 @@ The Rhai Scripting Language
|
||||
19. [Modules](language/modules/index.md)
|
||||
1. [Export Variables, Functions and Sub-Modules](language/modules/export.md)
|
||||
2. [Import Modules](language/modules/import.md)
|
||||
20. [Eval Statement](language/eval.md)
|
||||
20. [Eval Function](language/eval.md)
|
||||
6. [Safety and Protection](safety/index.md)
|
||||
1. [Checked Arithmetic](safety/checked.md)
|
||||
2. [Sand-Boxing](safety/sandbox.md)
|
||||
|
@@ -49,6 +49,8 @@ Reserved Keywords
|
||||
| --------- | --------------------- |
|
||||
| `var` | variable declaration |
|
||||
| `static` | variable declaration |
|
||||
| `begin` | block scope |
|
||||
| `end` | block scope |
|
||||
| `shared` | share value |
|
||||
| `each` | looping |
|
||||
| `then` | control flow |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
`eval` Statement
|
||||
`eval` Function
|
||||
===============
|
||||
|
||||
{{#include ../links.md}}
|
||||
|
@@ -5,21 +5,22 @@ Keywords
|
||||
|
||||
The following are reserved keywords in Rhai:
|
||||
|
||||
| Active keywords | Reserved keywords | Usage | Inactive under feature |
|
||||
| ------------------------------------------------- | ---------------------------------------------------------- | ---------------------- | :--------------------: |
|
||||
| `true`, `false` | | boolean constants | |
|
||||
| `let`, `const` | `var`, `static` | variable declarations | |
|
||||
| `is_shared` | | shared values | [`no_closure`] |
|
||||
| `if`, `else` | `then`, `goto`, `exit` | control flow | |
|
||||
| | `switch`, `match`, `case` | matching | |
|
||||
| `while`, `loop`, `for`, `in`, `continue`, `break` | `do`, `each` | looping | |
|
||||
| `fn`, `private` | `public`, `new` | functions | [`no_function`] |
|
||||
| `return` | | return values | |
|
||||
| `throw`, `try`, `catch` | | throw/catch exceptions | |
|
||||
| `import`, `export`, `as` | `use`, `with`, `module`, `package` | modules/packages | [`no_module`] |
|
||||
| `Fn`, `call`, `curry` | | function pointers | |
|
||||
| | `spawn`, `thread`, `go`, `sync`, `async`, `await`, `yield` | threading/async | |
|
||||
| `type_of`, `print`, `debug`, `eval` | | special functions | |
|
||||
| | `default`, `void`, `null`, `nil` | special values | |
|
||||
| Active keywords | Reserved keywords | Usage | Inactive under feature |
|
||||
| ---------------------------------------------------------------- | ---------------------------------------------------------- | ---------------------- | :--------------------: |
|
||||
| `true`, `false` | | constants | |
|
||||
| `let`, `const` | `var`, `static` | variables | |
|
||||
| | `begin`, `end` | block scopes | |
|
||||
| `is_shared` | | shared values | [`no_closure`] |
|
||||
| `if`, `else` | `then`, `unless`, `goto`, `exit` | control flow | |
|
||||
| `switch` | `match`, `case` | switching and matching | |
|
||||
| `do`, `while`, `loop`, `until`, `for`, `in`, `continue`, `break` | `each` | looping | |
|
||||
| `fn`, `private` | `public`, `new` | functions | [`no_function`] |
|
||||
| `return` | | return values | |
|
||||
| `throw`, `try`, `catch` | | throw/catch exceptions | |
|
||||
| `import`, `export`, `as` | `use`, `with`, `module`, `package` | modules/packages | [`no_module`] |
|
||||
| `Fn`, `call`, `curry` | | function pointers | |
|
||||
| | `spawn`, `thread`, `go`, `sync`, `async`, `await`, `yield` | threading/async | |
|
||||
| `type_of`, `print`, `debug`, `eval` | | special functions | |
|
||||
| | `default`, `void`, `null`, `nil` | special values | |
|
||||
|
||||
Keywords cannot become the name of a [function] or [variable], even when they are disabled.
|
||||
|
@@ -9,7 +9,7 @@ Terminated by '`;`'
|
||||
Statements are terminated by semicolons '`;`' and they are mandatory,
|
||||
except for the _last_ statement in a _block_ (enclosed by '`{`' .. '`}`' pairs) where it can be omitted.
|
||||
|
||||
Semicolons can also be omitted if the statement contains a block itself
|
||||
Semicolons can also be omitted if the statement ends with a block itself
|
||||
(e.g. the `if`, `while`, `for` and `loop` statements).
|
||||
|
||||
```rust
|
||||
@@ -35,6 +35,8 @@ Statement Expression
|
||||
A statement can be used anywhere where an expression is expected. These are called, for lack of a more
|
||||
creative name, "statement expressions."
|
||||
|
||||
The _last_ statement of a statement block is _always_ the block's return value when used as a statement.
|
||||
The _last_ statement of a statement block is _always_ the block's return value when used as a statement,
|
||||
_regardless_ of whether it is terminated by a semicolon or not. This is different from Rust where,
|
||||
if the last statement is terminated by a semicolon, the block's return value is taken to be `()`.
|
||||
|
||||
If the last statement has no return value (e.g. variable definitions, assignments) then it is assumed to be [`()`].
|
||||
|
Reference in New Issue
Block a user