From a35155b3e9ba9788d3e7fbc700ff751d2862be86 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 31 Jul 2020 17:07:09 +0800 Subject: [PATCH] Add shared and take to keywords list. --- doc/src/appendix/keywords.md | 61 ++++++++++++++-------------- doc/src/language/keywords.md | 31 +++++++------- doc/src/language/values-and-types.md | 3 +- doc/src/links.md | 1 + doc/src/start/features.md | 3 +- 5 files changed, 52 insertions(+), 47 deletions(-) diff --git a/doc/src/appendix/keywords.md b/doc/src/appendix/keywords.md index 5877f1a0..8aee03b1 100644 --- a/doc/src/appendix/keywords.md +++ b/doc/src/appendix/keywords.md @@ -3,35 +3,37 @@ Keywords List {{#include ../links.md}} -| Keyword | Description | Inactive under | -| :-------------------: | ---------------------------------------- | :-------------: | -| `true` | Boolean true literal | | -| `false` | Boolean false literal | | -| `let` | Variable declaration | | -| `const` | Constant declaration | | -| `if` | If statement | | -| `else` | else block of if statement | | -| `while` | While loop | | -| `loop` | Infinite loop | | -| `for` | For loop | | -| `in` | Containment test, part of for loop | | -| `continue` | Continue a loop at the next iteration | | -| `break` | Loop breaking | | -| `return` | Return value | | -| `throw` | Throw exception | | -| `import` | Import module | [`no_module`] | -| `export` | Export variable | [`no_module`] | -| `as` | Alias for variable export | [`no_module`] | -| `private` | Mark function private | [`no_function`] | -| `fn` (lower-case `f`) | Function definition | [`no_function`] | -| `Fn` (capital `F`) | Function to create a [function pointer] | | -| `call` | Call a [function pointer] | | -| `curry` | Curry a [function pointer] | | -| `this` | Reference to base object for method call | [`no_function`] | -| `type_of` | Get type name of value | | -| `print` | Print value | | -| `debug` | Print value in debug format | | -| `eval` | Evaluate script | | +| Keyword | Description | Inactive under | Overloadable | +| :-------------------: | ---------------------------------------- | :-------------: | :----------: | +| `true` | Boolean true literal | | No | +| `false` | Boolean false literal | | No | +| `let` | Variable declaration | | No | +| `const` | Constant declaration | | No | +| `shared` | Share value | [`no_shared`] | No | +| `take` | Un-share value | [`no_shared`] | No | +| `if` | If statement | | No | +| `else` | else block of if statement | | No | +| `while` | While loop | | No | +| `loop` | Infinite loop | | No | +| `for` | For loop | | No | +| `in` | Containment test, part of for loop | | No | +| `continue` | Continue a loop at the next iteration | | No | +| `break` | Loop breaking | | No | +| `return` | Return value | | No | +| `throw` | Throw exception | | No | +| `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`) | Function to create a [function pointer] | | Yes | +| `call` | Call a [function pointer] | | No | +| `curry` | Curry a [function pointer] | | No | +| `this` | Reference to base object for method call | [`no_function`] | No | +| `type_of` | Get type name of value | | Yes | +| `print` | Print value | | Yes | +| `debug` | Print value in debug format | | Yes | +| `eval` | Evaluate script | | Yes | Reserved Keywords @@ -59,7 +61,6 @@ Reserved Keywords | `package` | Package | | `spawn` | Threading | | `go` | Threading | -| `shared` | Threading | | `await` | Async | | `async` | Async | | `sync` | Async | diff --git a/doc/src/language/keywords.md b/doc/src/language/keywords.md index 509823db..a5142007 100644 --- a/doc/src/language/keywords.md +++ b/doc/src/language/keywords.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 | | -| `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 exceptions | | -| `import`, `export`, `as` | `use`, `with`, `module`, `package` | Modules/packages | [`no_module`] | -| `Fn`, `call`, `curry` | | Function pointers | | -| | `spawn`, `go`, `shared`, `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` | | Boolean constants | | +| `let`, `const` | `var`, `static` | Variable declarations | | +| `shared`, `take` | | Shared values | [`no_shared`] | +| `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 exceptions | | +| `import`, `export`, `as` | `use`, `with`, `module`, `package` | Modules/packages | [`no_module`] | +| `Fn`, `call`, `curry` | | Function pointers | | +| | `spawn`, `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. diff --git a/doc/src/language/values-and-types.md b/doc/src/language/values-and-types.md index 11426e84..833eead5 100644 --- a/doc/src/language/values-and-types.md +++ b/doc/src/language/values-and-types.md @@ -14,9 +14,10 @@ The following primitive types are supported natively: | **Immutable Unicode [string]** | `rhai::ImmutableString` (implemented as `Rc` or `Arc`) | `"string"` | `"hello"` etc. | | **[`Array`]** (disabled with [`no_index`]) | `rhai::Array` | `"array"` | `"[ ?, ?, ? ]"` | | **[Object map]** (disabled with [`no_object`]) | `rhai::Map` | `"map"` | `"#{ "a": 1, "b": 2 }"` | -| **[Timestamp]** (implemented in the [`BasicTimePackage`][packages], disabled with [`no_std`]) | `std::time::Instant` ([`instant::Instant`] if [WASM] build) | `"timestamp"` | _not supported_ | +| **[Timestamp]** (implemented in the [`BasicTimePackage`][packages], disabled with [`no_std`]) | `std::time::Instant` ([`instant::Instant`] if [WASM] build) | `"timestamp"` | `""` | | **[Function pointer]** | `rhai::FnPtr` | `Fn` | `"Fn(foo)"` | | **[`Dynamic`] value** (i.e. can be anything) | `rhai::Dynamic` | _the actual type_ | _actual value_ | +| **Shared value** (a reference-counted, shared [`Dynamic`] value) | | _the actual type_ | _actual value_ | | **System integer** (current configuration) | `rhai::INT` (`i32` or `i64`) | `"i32"` or `"i64"` | `"42"`, `"123"` etc. | | **System floating-point** (current configuration, disabled with [`no_float`]) | `rhai::FLOAT` (`f32` or `f64`) | `"f32"` or `"f64"` | `"123.456"` etc. | | **Nothing/void/nil/null/Unit** (or whatever it is called) | `()` | `"()"` | `""` _(empty string)_ | diff --git a/doc/src/links.md b/doc/src/links.md index 19fdf0e9..a22f0038 100644 --- a/doc/src/links.md +++ b/doc/src/links.md @@ -10,6 +10,7 @@ [`no_function`]: {{rootUrl}}/start/features.md [`no_module`]: {{rootUrl}}/start/features.md [`no_capture`]: {{rootUrl}}/start/features.md +[`no_shared`]: {{rootUrl}}/start/features.md [`no_std`]: {{rootUrl}}/start/features.md [`no-std`]: {{rootUrl}}/start/features.md [`internals`]: {{rootUrl}}/start/features.md diff --git a/doc/src/start/features.md b/doc/src/start/features.md index efeb39c5..9f0d42d4 100644 --- a/doc/src/start/features.md +++ b/doc/src/start/features.md @@ -24,7 +24,8 @@ more control over what a script can (or cannot) do. | `no_function` | Disable script-defined [functions]. | | `no_module` | Disable loading external [modules]. | | `no_capture` | Disable [capturing][capture] external variables in [anonymous functions] and [capturing the calling scope]({{rootUrl}}/language/fn-capture.md) in function calls. | -| `no_std` | Build for `no-std`. Notice that additional dependencies will be pulled in to replace `std` features. | +| `no_shared` | Disable sharing of data values. | +| `no_std` | Build for `no-std` (implies `no_shared`). Notice that additional dependencies will be pulled in to replace `std` features. | | `serde` | Enable serialization/deserialization via `serde`. Notice that the [`serde`](https://crates.io/crates/serde) crate will be pulled in together with its dependencies. | | `internals` | Expose internal data structures (e.g. [`AST`] nodes). Beware that Rhai internals are volatile and may change from version to version. | | `unicode-xid-ident` | Allow [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) as identifiers. |