rhai/RELEASES.md

258 lines
14 KiB
Markdown
Raw Normal View History

2020-05-18 03:36:34 +02:00
Rhai Release Notes
==================
2020-07-14 02:42:02 +02:00
Version 0.18.0
==============
2020-07-19 11:14:55 +02:00
This version adds:
2020-07-26 12:17:55 +02:00
* Binding the `this` pointer in a function pointer `call`.
* Anonymous functions (in Rust closure syntax). Simplifies creation of single-use ad-hoc functions.
2020-07-22 17:12:09 +02:00
* Currying of function pointers.
2020-07-19 11:14:55 +02:00
2020-07-16 06:09:31 +02:00
New features
------------
* `call` can now be called function-call style for function pointers - this is to handle builds with `no_object`.
2020-07-26 12:17:55 +02:00
* Reserve language keywords, such as `print`, `eval`, `call`, `this` etc.
* `x.call(f, ...)` allows binding `x` to `this` for the function referenced by the function pointer `f`.
2020-07-26 12:17:55 +02:00
* Anonymous functions are supported in the syntax of a Rust closure, e.g. `|x, y, z| x + y - z`.
* Custom syntax now works even without the `internals` feature.
2020-07-26 12:17:55 +02:00
* Currying of function pointers is supported via the new `curry` keyword.
2020-07-24 17:16:54 +02:00
* `Module::set_indexer_get_set_fn` is added as a shorthand of both `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn`.
2020-07-14 02:42:02 +02:00
2020-07-22 07:08:51 +02:00
Breaking changes
----------------
2020-07-26 12:17:55 +02:00
* Language keywords are now _reserved_ (even when disabled) and they can no longer be used as variable names.
2020-07-22 07:08:51 +02:00
* Function signature for defining custom syntax is simplified.
2020-07-26 12:17:55 +02:00
* `Engine::register_raw_fn_XXX` API shortcuts are removed.
Housekeeping
------------
* Most compilation warnings are eliminated via feature gates.
2020-07-22 07:08:51 +02:00
2020-07-14 02:42:02 +02:00
2020-07-01 17:29:36 +02:00
Version 0.17.0
==============
2020-07-05 09:23:51 +02:00
This version adds:
2020-07-05 11:41:45 +02:00
* [`serde`](https://crates.io/crates/serde) support for working with `Dynamic` values (particularly _object maps_).
2020-07-13 13:38:50 +02:00
* Low-level API to register functions.
2020-07-13 07:41:01 +02:00
* Surgically disable keywords and/or operators in the language.
* Define custom operators.
* Extend the language via custom syntax.
2020-07-04 09:39:40 +02:00
2020-07-09 16:21:07 +02:00
Bug fixes
---------
* Fixed method calls in the middle of a dot chain.
2020-07-03 04:45:01 +02:00
Breaking changes
----------------
* `EvalAltResult::ErrorMismatchOutputType` has an extra argument containing the name of the requested type.
2020-07-05 17:08:44 +02:00
* `Engine::call_fn_dynamic` take an extra argument, allowing a `Dynamic` value to be bound to the `this` pointer.
* Precedence of the `%` (modulo) operator is lowered to below `<<` ad `>>`. This is to handle the case of `x << 3 % 10`.
2020-07-01 17:29:36 +02:00
2020-07-04 09:39:40 +02:00
New features
------------
* New `serde` feature to allow serializing/deserializing to/from `Dynamic` values using [`serde`](https://crates.io/crates/serde).
2020-07-04 09:39:40 +02:00
This is particularly useful when converting a Rust `struct` to a `Dynamic` _object map_ and back.
2020-07-05 09:23:51 +02:00
* `Engine::disable_symbol` to surgically disable keywords and/or operators.
2020-07-05 11:41:45 +02:00
* `Engine::register_custom_operator` to define a custom operator.
2020-07-14 02:42:02 +02:00
* `Engine::register_custom_syntax` to define a custom syntax.
2020-07-26 12:17:55 +02:00
* New low-level API `Engine::register_raw_fn`.
2020-07-07 16:59:23 +02:00
* New low-level API `Module::set_raw_fn` mirroring `Engine::register_raw_fn`.
2020-07-06 04:02:54 +02:00
* `AST::clone_functions_only`, `AST::clone_functions_only_filtered` and `AST::clone_statements_only` to clone only part of an `AST`.
* The boolean `^` (XOR) operator is added.
2020-07-07 16:59:23 +02:00
* `FnPtr` is exposed as the function pointer type.
2020-07-08 03:48:25 +02:00
* `rhai::module_resolvers::ModuleResolversCollection` added to try a list of module resolvers.
2020-07-09 13:54:28 +02:00
* It is now possible to mutate the first argument of a module-qualified function call when the argument is a simple variable (but not a module constant).
2020-07-13 07:41:01 +02:00
* Many configuration/setting API's now returns `&mut Self` so that the calls can be chained.
* `String` parameters in functions are supported (but inefficiently).
2020-07-04 09:39:40 +02:00
2020-07-13 13:38:50 +02:00
2020-07-01 16:21:43 +02:00
Version 0.16.1
==============
Bug fix release to fix errors when compiling with features.
2020-06-26 04:39:18 +02:00
Version 0.16.0
2020-06-18 07:01:07 +02:00
==============
2020-06-26 04:39:18 +02:00
The major new feature in this version is OOP - well, poor man's OOP, that is.
2020-07-01 16:21:43 +02:00
The `README` is officially transferred to [The Rhai Book](https://schungx.github.io/rhai).
An online [Playground](https://alvinhochun.github.io/rhai-demo/) is available.
Breaking changes
----------------
* The trait function `ModuleResolver::resolve` no longer takes a `Scope` as argument.
2020-06-26 04:39:18 +02:00
* Functions defined in script now differentiates between using method-call style and normal function-call style.
The method-call style will bind the object to the `this` parameter instead of consuming the first parameter.
* Imported modules are no longer stored in the `Scope`. `Scope::push_module` is removed.
2020-06-28 09:49:24 +02:00
Therefore, cannot rely on module imports to persist across invocations using a `Scope`.
* `AST::retain_functions` is used for another purpose. The old `AST::retain_functions` is renamed to `AST::clear_statements`.
2020-06-25 12:07:57 +02:00
New features
------------
* Support for _function pointers_ via `Fn(name)` and `Fn.call(...)` syntax - a poor man's first-class function.
2020-06-26 04:39:18 +02:00
* Support for calling script-defined functions in method-call style with `this` binding to the object.
* Special support in object maps for OOP.
* Expanded the `AST` API for fine-tuned manipulation of functions.
2020-06-25 12:07:57 +02:00
2020-06-21 04:37:17 +02:00
Enhancements
------------
* [The Rhai Book](https://schungx.github.io/rhai) is online. Most content in the original `README` was transferred to the Book.
2020-06-23 04:43:24 +02:00
* New feature `internals` to expose internal data structures (e.g. the AST nodes).
2020-06-21 04:37:17 +02:00
2020-06-18 07:01:07 +02:00
2020-06-10 16:28:50 +02:00
Version 0.15.1
2020-06-01 07:26:02 +02:00
==============
2020-06-10 16:28:50 +02:00
This is a minor release which enables updating indexers (via registered indexer setters) and supports functions
2020-06-17 03:54:17 +02:00
with `&str` parameters (maps transparently to `ImmutableString`). WASM is also a tested target.
2020-06-10 16:28:50 +02:00
2020-06-18 07:01:07 +02:00
Bug fix
-------
* `let s="abc"; s[1].change_to('X');` now correctly sets the character '`X`' into '`s`' yielding `"aXc"`.
2020-06-02 07:33:16 +02:00
Breaking changes
----------------
* Callback closure passed to `Engine::on_progress` now takes `&u64` instead of `u64` to be consistent with other callback signatures.
2020-06-06 07:06:00 +02:00
* `Engine::register_indexer` is renamed to `Engine::register_indexer_get`.
* `Module::set_indexer_fn` is renamed to `Module::set_indexer_get_fn`.
* The tuple `ParseError` now exposes the internal fields and the `ParseError::error_type` and `ParseError::position` methods are removed. The first tuple field is the `ParseErrorType` and the second tuple field is the `Position`.
* `Engine::call_fn_dynamic` now takes any type that implements `IntoIterator<Item = Dynamic>`.
2020-06-06 07:06:00 +02:00
New features
------------
2020-06-10 16:28:50 +02:00
* Indexers are now split into getters and setters (which now support updates). The API is split into `Engine::register_indexer_get` and `Engine::register_indexer_set` with `Engine::register_indexer_get_set` being a shorthand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added.
* `Engine:register_fn` and `Engine:register_result_fn` accepts functions that take parameters of type `&str` (immutable string slice), which maps directly to `ImmutableString`. This is to avoid needing wrappers for functions taking string parameters.
2020-06-14 08:25:47 +02:00
* Set maximum limit on data sizes: `Engine::set_max_string_size`, `Engine::set_max_array_size` and `Engine::set_max_map_size`.
2020-06-16 16:14:46 +02:00
* Supports trailing commas on array literals, object map literals, function definitions and function calls.
2020-06-17 03:54:17 +02:00
* Enhances support for compiling to WASM.
2020-06-01 07:26:02 +02:00
2020-06-18 07:01:07 +02:00
2020-06-01 07:26:02 +02:00
Version 0.15.0
==============
2020-06-10 16:28:50 +02:00
This version uses immutable strings (`ImmutableString` type) and built-in operator functions (e.g. `+`, `>`, `+=`) to improve speed, plus some bug fixes.
2020-05-26 08:14:03 +02:00
Regression fix
--------------
2020-05-19 18:06:07 +02:00
* Do not optimize script with `eval_expression` - it is assumed to be one-off and short.
Bug fixes
---------
* Indexing with an index or dot expression now works property (it compiled wrongly before).
2020-05-31 09:55:02 +02:00
For example, `let s = "hello"; s[s.len-1] = 'x';` now works property instead of causing a runtime error.
* `if` expressions are not supposed to be allowed when compiling for expressions only. This is fixed.
2020-05-23 12:59:28 +02:00
Breaking changes
----------------
* `Engine::compile_XXX` functions now return `ParseError` instead of `Box<ParseError>`.
* The `RegisterDynamicFn` trait is merged into the `RegisterResultFn` trait which now always returns `Result<Dynamic, Box<EvalAltResult>>`.
2020-05-23 12:59:28 +02:00
* 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 under `Engine::new_raw`.
* Strings are now immutable. The type `rhai::ImmutableString` is used instead of `std::string::String`. This is to avoid excessive cloning of strings. All native-Rust functions taking string parameters should switch to `rhai::ImmutableString` (which is either `Rc<String>` or `Arc<String>` depending on whether the `sync` feature is used).
* Native Rust functions registered with the `Engine` also mutates the first argument when called in normal function-call style (previously the first argument will be passed by _value_ if not called in method-call style). Of course, if the first argument is a calculated value (e.g. result of an expression), then mutating it has no effect, but at least it is not cloned.
* Some built-in methods (e.g. `len` for string, `floor` for `FLOAT`) now have _property_ versions in addition to methods to simplify coding.
2020-05-23 12:59:28 +02:00
New features
------------
2020-05-23 12:59:28 +02:00
* Set limit on maximum level of nesting expressions and statements to avoid panics during parsing.
2020-05-21 11:11:01 +02:00
* New `EvalPackage` to disable `eval`.
* `Module::set_getter_fn`, `Module::set_setter_fn` and `Module:set_indexer_fn` to register getter/setter/indexer functions.
2020-05-31 06:37:19 +02:00
* `Engine::call_fn_dynamic` for more control in calling script functions.
2020-05-23 18:29:06 +02:00
Speed enhancements
------------------
* Common operators (e.g. `+`, `>`, `==`) now call into highly efficient built-in implementations for standard types (i.e. `INT`, `FLOAT`, `bool`, `char`, `()` and `ImmutableString`) if not overridden by a registered function. This yields a 5-10% speed benefit depending on script operator usage. Scripts running tight loops will see significant speed-up.
* Common assignment operators (e.g. `+=`, `%=`) now call into highly efficient built-in implementations for standard types (i.e. `INT`, `FLOAT`, `bool`, `char`, `()` and `ImmutableString`) if not overridden by a registered function.
* 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`.
2020-05-26 08:14:03 +02:00
* Operator-assignment statements (e.g. `+=`) are now handled directly and much faster.
* Strings are now _immutable_ and use the `rhai::ImmutableString` type, eliminating large amounts of cloning.
* For Native Rust functions taking a first `&mut` parameter, the first argument is passed by reference instead of by value, even if not called in method-call style. This allows many functions declared with `&mut` parameter to avoid excessive cloning. For example, if `a` is a large array, getting its length in this manner: `len(a)` used to result in a full clone of `a` before taking the length and throwing the copy away. Now, `a` is simply passed by reference, avoiding the cloning altogether.
* A custom hasher simply passes through `u64` keys without hashing to avoid function call hash keys (which are by themselves `u64`) being hashed twice.
2020-05-23 18:29:06 +02:00
2020-05-18 03:36:34 +02:00
Version 0.14.1
==============
The major features for this release is modules, script resource limits, and speed improvements
(mainly due to avoiding allocations).
New features
------------
* Modules and _module resolvers_ allow loading external scripts under a module namespace. A module can contain constant variables, Rust functions and Rhai functions.
2020-05-18 03:36:34 +02:00
* `export` variables and `private` functions.
* _Indexers_ for Rust types.
* Track script evaluation progress and terminate script run.
* Set limit on maximum number of operations allowed per script run.
* Set limit on maximum number of modules loaded per script run.
* A new API, `Engine::compile_scripts_with_scope`, can compile a list of script segments without needing to first concatenate them together into one large string.
2020-05-18 03:36:34 +02:00
* Stepped `range` function with a custom step.
Speed improvements
------------------
### `StaticVec`
A script contains many lists - statements in a block, arguments to a function call etc.
In a typical script, most of these lists tend to be short - e.g. the vast majority of function calls contain
fewer than 4 arguments, while most statement blocks have fewer than 4-5 statements, with one or two being
the most common. Before, dynamic `Vec`'s are used to hold these short lists for very brief periods of time,
causing allocations churn.
In this version, large amounts of allocations are avoided by converting to a `StaticVec` -
a list type based on a static array for a small number of items (currently four) -
wherever possible plus other tricks. Most real-life scripts should see material speed increases.
### Pre-computed variable lookups
Almost all variable lookups, as well as lookups in loaded modules, are now pre-computed.
A variable's name is almost never used to search for the variable in the current scope.
_Getters_ and _setter_ function names are also pre-computed and cached, so no string allocations are
performed during a property get/set call.
### Pre-computed function call hashes
Lookup of all function calls, including Rust and Rhai ones, are now through pre-computed hashes.
The function name is no longer used to search for a function, making function call dispatches
much faster.
### Large Boxes for expressions and statements
The expression (`Expr`) and statement (`Stmt`) types are modified so that all of the variants contain only
one single `Box` to a large allocated structure containing _all_ the fields. This makes the `Expr` and
`Stmt` types very small (only one single pointer) and improves evaluation speed due to cache efficiency.
Error handling
--------------
Previously, when an error occurs inside a function call, the error position reported is the function
call site. This makes it difficult to diagnose the actual location of the error within the function.
A new error variant `EvalAltResult::ErrorInFunctionCall` is added in this version.
It wraps the internal error returned by the called function, including the error position within the function.