This commit is contained in:
Stephen Chung 2020-05-24 23:42:40 +08:00
parent fd6dad0253
commit bbed4c6ef4
3 changed files with 20 additions and 5 deletions

View File

@ -11,7 +11,8 @@ Rhai - Embedded Scripting for Rust
Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy way Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy way
to add scripting to any application. to add scripting to any application.
Rhai's current features set: Features
--------
* Easy-to-use language similar to JS+Rust with dynamic typing but _no_ garbage collector. * Easy-to-use language similar to JS+Rust with dynamic typing but _no_ garbage collector.
* Tight integration with native Rust [functions](#working-with-functions) and [types](#custom-types-and-methods), * Tight integration with native Rust [functions](#working-with-functions) and [types](#custom-types-and-methods),
@ -38,6 +39,19 @@ Rhai's current features set:
**Note:** Currently, the version is 0.14.2, so the language and API's may change before they stabilize. **Note:** Currently, the version is 0.14.2, so the language and API's may change before they stabilize.
What Rhai doesn't do
--------------------
Rhai's purpose is to provide a dynamic layer over Rust code, in the same spirit of _zero cost abstractions_.
It doesn't attempt to be a new language. For example:
* No classes. Well, Rust doesn't either. On the other hand...
* No traits... so it is also not Rust. Do your Rusty stuff in Rust.
* No structures - definte your types in Rust instead; Rhai can seamless work with _any Rust type_.
* No first-class functions - Code your functions in Rust instead, and register them with Rhai.
* No closures - do your closure magic in Rust instead; [turn a Rhai scripted function into a Rust closure](#calling-rhai-functions-from-rust).
* It is best to expose an API in Rhai for scripts to call. All your core functionalities should be in Rust.
Installation Installation
------------ ------------

View File

@ -17,7 +17,7 @@ Breaking changes
`Result<Dynamic, Box<EvalAltResult>>`. `Result<Dynamic, Box<EvalAltResult>>`.
* Default maximum limit on levels of nested function calls is fine-tuned and set to a different value. * Default maximum limit on levels of nested function calls is fine-tuned and set to a different value.
* Some operator functions are now built in (see _Speed enhancements_ below), so they are available even * Some operator functions are now built in (see _Speed enhancements_ below), so they are available even
when under `Engine::new_raw`. under `Engine::new_raw`.
New features New features
------------ ------------
@ -31,7 +31,8 @@ Speed enhancements
* Common operators (e.g. `+`, `>`, `==`) now call into highly efficient built-in implementations for standard types * Common operators (e.g. `+`, `>`, `==`) now call into highly efficient built-in implementations for standard types
(i.e. `INT`, `FLOAT`, `bool`, `char`, `()` and some `String`) if not overridden by a registered function. (i.e. `INT`, `FLOAT`, `bool`, `char`, `()` and some `String`) if not overridden by a registered function.
This yields a 5-10% speed benefit depending on script operator usage. This yields a 5-10% speed benefit depending on script operator usage. Scripts running tight loops will see
significant speed-up.
* Implementations of common operators for standard types are removed from the `ArithmeticPackage` and `LogicPackage` * Implementations of common operators for standard types are removed from the `ArithmeticPackage` and `LogicPackage`
(and therefore the `CorePackage`) because they are now always available, even under `Engine::new_raw`. (and therefore the `CorePackage`) because they are now always available, even under `Engine::new_raw`.

View File

@ -21,8 +21,8 @@ type LERR = LexError;
/// A location (line number + character position) in the input script. /// A location (line number + character position) in the input script.
/// ///
/// In order to keep footprint small, both line number and character position have 16-bit resolution, /// In order to keep footprint small, both line number and character position have 16-bit unsigned resolution,
/// meaning they go up to a maximum of 65,535 lines/characters per line. /// meaning they go up to a maximum of 65,535 lines and characters per line.
/// Advancing beyond the maximum line length or maximum number of lines is not an error but has no effect. /// Advancing beyond the maximum line length or maximum number of lines is not an error but has no effect.
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
pub struct Position { pub struct Position {