2020-05-18 03:36:34 +02:00
Rhai Release Notes
==================
2020-12-30 14:12:51 +01:00
Version 0.19.10
===============
Breaking changes
----------------
* The error variant `EvalAltResult::ErrorInFunctionCall` has a new parameter holding the _source_ of the function.
2021-01-03 13:54:08 +01:00
* `ParseErrorType::WrongFnDefinition` is renamed `FnWrongDefinition` .
* Redefining an existing function within the same script now throws a new `ParseErrorType::FnDuplicatedDefinition` . This is to prevent accidental overwriting an earlier function definition.
2021-01-09 08:20:07 +01:00
* `AST::set_source` is now split into `AST::set_source` and `AST::clear_source` .
2020-12-30 14:12:51 +01:00
2021-01-08 17:24:55 +01:00
New features
------------
* `Engine::compile_to_self_contained` compiles a script into an `AST` and _eagerly_ resolves all `import` statements with string literal paths. The resolved modules are directly embedded into the `AST` . When the `AST` is later evaluated, `import` statements directly yield the pre-resolved modules without going through the resolution process once again.
2021-01-09 09:52:22 +01:00
* `AST::walk` , `Stmt::walk` and `Expr::walk` internal API's to recursively walk an `AST` .
2021-01-08 17:24:55 +01:00
2020-12-30 14:12:51 +01:00
Enhancements
------------
* Source information is provided when there is an error within a call to a function defined in another module.
2021-01-02 17:20:13 +01:00
* Source information is provided to the `NativeCallContext` for native Rust functions.
2021-01-08 07:29:57 +01:00
* `EvalAltResult::clear_position` to clear the position information of an error - useful when only the message is needed and the position doesn't need to be printed out.
2020-12-30 14:12:51 +01:00
2020-12-22 15:35:25 +01:00
Version 0.19.9
==============
2020-12-28 02:49:54 +01:00
This version fixes a bug introduced in `0.19.8` which breaks property access
within closures.
It also removes the confusing differences between _packages_ and _modules_
2020-12-23 03:08:43 +01:00
by unifying the terminology and API under the global umbrella of _modules_ .
2020-12-27 09:50:48 +01:00
Bug fixes
---------
2020-12-28 07:21:13 +01:00
* Fix bug when accessing properties in closures.
* Fix bug when accessing a deep index with a function call.
2020-12-29 03:41:20 +01:00
* Fix bug that sometimes allow assigning to an invalid l-value.
2020-12-29 05:29:45 +01:00
* Fix off-by-one error with `Engine::set_max_call_levels` .
2020-12-27 09:50:48 +01:00
2020-12-22 16:45:14 +01:00
Breaking changes
----------------
2020-12-23 03:08:43 +01:00
* `Engine::load_package` is renamed `Engine::register_global_module` and now must explicitly pass a shared [`Module`].
* `Engine::register_module` is renamed `Engine::register_static_module` and now must explicitly pass a shared [`Module`].
2020-12-22 16:45:14 +01:00
* `Package::get` is renamed `Package::as_shared_module` .
2020-12-26 06:05:57 +01:00
* `Engine::set_module_resolver` now takes a straight module resolver instead of an `Option` . To disable module resolving, use the new `DummyModuleResolver` .
2020-12-22 16:45:14 +01:00
2020-12-24 02:42:03 +01:00
Enhancements
------------
* `Scope` is now `Clone + Hash` .
2020-12-26 06:05:57 +01:00
* `Engine::register_static_module` now supports sub-module paths (e.g. `foo::bar::baz` ).
2020-12-26 16:21:09 +01:00
* `Engine::register_custom_operator` now accepts reserved symbols.
* `Engine::register_custom_operator` now returns an error if given a precedence of zero.
2020-12-29 08:36:42 +01:00
* The examples `repl` and `rhai_runner` are moved into `bin` and renamed `rhai-repl` and `rhai-run` respectively.
2020-12-24 02:42:03 +01:00
2020-12-22 15:35:25 +01:00
2020-12-08 15:20:29 +01:00
Version 0.19.8
==============
2020-12-13 07:31:24 +01:00
This version makes it easier to generate documentation for a Rhai code base.
Each function defined in an `AST` can optionally attach _doc-comments_ (which, as in Rust,
are comments prefixed by either `///` or `/**` ). Doc-comments allow third-party tools to
automatically generate documentation for functions defined in a Rhai script.
2020-12-22 04:13:13 +01:00
A new API, `Engine::gen_fn_metadata_to_json` and `Engine::gen_fn_metadata_with_ast_to_json` ,
paired with the new `metadata` feature, exports the full list of functions metadata
(including those in an `AST` ) as a JSON document.
2020-12-20 05:27:47 +01:00
2020-12-22 15:35:25 +01:00
There are also a sizable number of bug fixes.
2020-12-08 15:20:29 +01:00
Bug fixes
---------
2020-12-21 10:39:37 +01:00
* Unary prefix operators `-` , `+` and `!` now bind correctly when applied to an expression. Previously, `-x.len` is parsed as `(-x).len` which is obviously counter-intuitive.
* Indexing of namespace-qualified variables now work properly, such as `path::to::var[x]` .
2020-12-08 15:20:29 +01:00
* Constants are no longer propagated by the optimizer if shadowed by a non-constant variable.
2020-12-22 15:35:25 +01:00
* A constant passed as the `this` parameter to Rhai functions now throws an error if assigned to.
2020-12-14 08:15:05 +01:00
* Generic type parameter of `Engine::register_iterator` is `IntoIterator` instead of `Iterator` .
2020-12-18 09:07:19 +01:00
* Fixes parsing of block comments ending with `**/` or inner blocks starting with `//*` .
2020-12-08 15:20:29 +01:00
2020-12-12 03:10:27 +01:00
Breaking changes
----------------
* `Engine::on_progress` now takes `u64` instead of `&u64` .
2020-12-21 15:04:46 +01:00
* The closure for `Engine::on_debug` now takes two additional parameters: `source: Option<&str>` and `pos: Position` .
2020-12-12 11:44:28 +01:00
* `AST::iter_functions` now returns `ScriptFnMetadata` .
2020-12-15 12:23:30 +01:00
* The parser function passed to `Engine::register_custom_syntax_raw` now takes an additional parameter containing the _look-ahead_ symbol.
2020-12-12 03:10:27 +01:00
2020-12-13 07:31:24 +01:00
New features
------------
* `AST::iter_functions` now returns `ScriptFnMetadata` which includes, among others, _doc-comments_ for functions prefixed by `///` or `/**` .
2020-12-20 13:05:23 +01:00
* _Doc-comments_ can be enabled/disabled with the new `Engine::set_doc_comments` method.
2020-12-22 15:35:25 +01:00
* A new feature `metadata` is added that pulls in `serde_json` and enables `Engine::gen_fn_metadata_to_json` and `Engine::gen_fn_metadata_with_ast_to_json` which exports the full list of functions metadata (including those inside an `AST` ) in JSON format.
* `Engine::on_debug` provides two additional parameters: `source: Option<&str>` and `pos: Position` , containing the current source (if any) and position of the `debug` statement.
2020-12-21 16:12:45 +01:00
* `NativeCallContext` and `EvalContext` both expose `source()` which returns the current source, if any.
2020-12-13 07:31:24 +01:00
2020-12-09 14:06:36 +01:00
Enhancements
------------
2020-12-20 13:05:23 +01:00
* A functions lookup cache is added to make function call resolution faster.
2020-12-09 14:06:36 +01:00
* Capturing a constant variable in a closure is now supported, with no cloning.
2020-12-15 12:23:30 +01:00
* A _look-ahead_ symbol is provided to custom syntax parsers, which can be used to parse variable-length symbol streams.
2020-12-09 14:06:36 +01:00
2020-12-08 15:20:29 +01:00
2020-11-24 02:40:08 +01:00
Version 0.19.7
==============
2020-11-29 17:52:21 +01:00
Bug fixes
---------
* Fixes compilation errors with certain feature flag combinations.
Enhancements
------------
* Property getters/setters and indexers defined in a plugin module are by default `#[rhai_fn(global)]` .
2020-11-30 04:20:51 +01:00
* `to_debug` is a new standard function for converting a value into debug format.
* Arrays and object maps now print values using `to_debug` (if available).
2020-11-29 17:52:21 +01:00
2020-11-24 02:40:08 +01:00
2020-11-13 11:32:18 +01:00
Version 0.19.6
==============
This version adds the `switch` statement.
2020-11-17 05:23:53 +01:00
It also allows exposing selected module functions (usually methods) to the global namespace.
2020-11-20 09:52:28 +01:00
This is very convenient when encapsulating the API of a custom Rust type into a module while having methods
and iterators registered on the custom type work normally.
2020-11-17 05:23:53 +01:00
2020-11-22 10:21:34 +01:00
A new `gen_fn_signatures` API enables enumerating the registered functions of an `Engine` for documentation purposes.
It also prepares the way for a future reflection API.
2020-11-21 06:05:57 +01:00
Bug fixes
---------
* Custom syntax that introduces a shadowing variable now works properly.
2020-11-17 08:11:58 +01:00
Breaking changes
----------------
* `Module::set_fn` , `Module::set_raw_fn` and `Module::set_fn_XXX_mut` all take an additional parameter of `FnNamespace` .
2020-11-22 15:15:17 +01:00
* `Module::set_fn` takes a further parameter with a list of parameter names/types plus the function return type, if any.
2020-11-21 15:18:32 +01:00
* `Module::get_sub_module_mut` is removed.
2020-11-21 08:44:17 +01:00
* `begin` , `end` , `unless` are now reserved keywords.
2020-11-21 08:08:18 +01:00
* `EvalPackage` is removed in favor of `Engine::disable_symbol` .
2020-11-17 08:11:58 +01:00
2020-11-13 11:32:18 +01:00
New features
------------
2020-11-22 10:21:34 +01:00
* New `switch` statement.
* New `do ... while` and `do ... until` statements.
* New `Engine::gen_fn_signatures` , `Module::gen_fn_signatures` and `PackagesCollection::gen_fn_signatures` to generate a list of signatures for functions registered.
2020-12-22 16:45:14 +01:00
* New `Engine::register_static_module` to register a module as a sub-module in the global namespace.
2020-11-22 10:21:34 +01:00
* New `set_exported_global_fn!` macro to register a plugin function and expose it to the global namespace.
2020-11-17 08:11:58 +01:00
* `Module::set_fn_XXX_mut` can expose a module function to the global namespace. This is convenient when registering an API for a custom type.
* `Module::set_getter_fn` , `Module::set_setter_fn` , `Module::set_indexer_get_fn` , `Module::set_indexer_set_fn` all expose the function to the global namespace by default. This is convenient when registering an API for a custom type.
2020-11-22 15:15:17 +01:00
* New `Module::update_fn_metadata` to update a module function's parameter names and types.
2020-11-22 10:21:34 +01:00
* New `#[rhai_fn(global)]` and `#[rhai_fn(internal)]` attributes to determine whether a function defined in a plugin module should be exposed to the global namespace. This is convenient when defining an API for a custom type.
2020-11-23 12:11:32 +01:00
* New `get_fn_metadata_list` to get the metadata of all script-defined functions in scope.
2020-11-15 16:14:29 +01:00
Enhancements
------------
2020-11-20 09:52:28 +01:00
* New constants under `Dynamic` including `UNIT` , `TRUE` , `FALSE` , `ZERO` , `ONE` etc.
2020-11-24 02:40:08 +01:00
* Floating-point numbers ending with a decimal point without a trailing `0` are supported.
2020-11-13 11:32:18 +01:00
2020-11-06 12:17:07 +01:00
Version 0.19.5
==============
2020-11-08 07:29:54 +01:00
This version fixes a bug that prevents compilation with the `internals` feature.
It also speeds up importing modules.
Bug fixes
---------
* Fixes compilation error when using the `internals` feature. Bug introduced in `0.19.4` .
2020-11-08 16:00:37 +01:00
* Importing script files recursively no longer panics.
2020-11-08 07:29:54 +01:00
2020-11-06 12:17:07 +01:00
Breaking changes
----------------
* Modules imported at global level can now be accessed in functions.
2020-11-07 16:33:21 +01:00
* `ModuleResolver::resolve` now returns `Shared<Module>` for better resources sharing when loading modules.
2020-11-09 14:52:23 +01:00
* `ParseErrorType::DuplicatedExport` is removed as multiple `export` 's are now allowed.
2020-11-07 16:33:21 +01:00
Enhancements
------------
* Modules imported via `import` statements at global level can now be used in functions. There is no longer any need to re-`import` the modules at the beginning of each function block.
2020-11-09 14:52:23 +01:00
* Modules imported via `import` statements are encapsulated into the `AST` when loading a module from a script file.
* `export` keyword can now be tagged onto `let` and `const` statements as a short-hand, e.g.: `export let x = 42;`
2020-11-09 07:38:33 +01:00
* Variables can now be `export` -ed multiple times under different names.
2020-11-08 16:00:37 +01:00
* `index_of` , `==` and `!=` are defined for arrays.
* `==` and `!=` are defined for object maps.
2020-11-06 12:17:07 +01:00
2020-10-17 07:49:16 +02:00
2020-10-24 18:39:47 +02:00
Version 0.19.4
==============
2020-10-29 04:37:51 +01:00
This version basically cleans up the code structure in preparation for a potential `1.0` release in the future.
2020-10-31 16:26:21 +01:00
Most scripts should see a material speed increase.
2020-10-29 04:37:51 +01:00
This version also adds a low-level API for more flexibility when defining custom syntax.
2020-10-26 12:46:58 +01:00
2020-10-25 14:48:18 +01:00
Bug fixes
---------
* Fixes `Send + Sync` for `EvalAltResult` under the `sync` feature. Bug introduced with `0.19.3` .
2020-10-26 12:46:58 +01:00
Breaking changes
----------------
* Custom syntax can no longer start with a keyword (even a _reserved_ one), even if it has been disabled. That is to avoid breaking scripts later when the keyword is no longer disabled.
2020-11-03 14:50:14 +01:00
Changes to Error Handling
------------------------
2020-10-28 03:26:36 +01:00
* `EvalAltResult::ErrorAssignmentToUnknownLHS` is moved to `ParseError::AssignmentToInvalidLHS` . `ParseError::AssignmentToCopy` is removed.
2020-11-02 04:04:45 +01:00
* `EvalAltResult::ErrorDataTooLarge` is simplified.
* `Engine::on_progress` closure signature now returns `Option<Dynamic>` with the termination value passed on to `EvalAltResult::ErrorTerminated` .
2020-11-02 05:50:27 +01:00
* `ParseErrorType::BadInput` now wraps a `LexError` instead of a text string.
2020-10-26 12:46:58 +01:00
2020-10-24 18:39:47 +02:00
New features
------------
2020-11-01 09:02:10 +01:00
* `f32_float` feature to set `FLOAT` to `f32` .
2020-10-26 12:46:58 +01:00
* Low-level API for custom syntax allowing more flexibility in designing the syntax.
2020-10-24 18:39:47 +02:00
* `Module::fill_with` to poly-fill a module with another.
2020-11-03 14:50:14 +01:00
* Scripts terminated via `Engine::on_progress` can now pass on a value as a termination token.
2020-10-24 18:39:47 +02:00
2020-10-28 12:11:17 +01:00
Enhancements
------------
2020-10-31 16:26:21 +01:00
* Essential AST structures like `Expr` and `Stmt` are packed into smaller sizes (16 bytes and 32 bytes on 64-bit), stored inline for more cache friendliness, and de-`Box`ed as much as possible.
2020-11-03 14:50:14 +01:00
* `Scope` is optimized for cache friendliness.
2020-10-28 12:11:17 +01:00
2020-10-24 18:39:47 +02:00
2020-10-17 07:49:16 +02:00
Version 0.19.3
==============
2020-10-20 17:16:03 +02:00
This version streamlines some of the advanced API's, and adds the `try` ... `catch` statement
to catch exceptions.
2020-10-17 10:34:07 +02:00
Breaking changes
----------------
* `EvalAltResult::ErrorReadingScriptFile` is removed in favor of the new `EvalAltResult::ErrorSystem` .
* `EvalAltResult::ErrorLoopBreak` is renamed to `EvalAltResult::LoopBreak` .
2020-10-18 16:10:08 +02:00
* `Engine::register_raw_fn` and `FnPtr::call_dynamic` function signatures have changed.
2020-10-19 13:11:55 +02:00
* Callback signatures to `Engine::on_var` and `Engine::register_custom_syntax` have changed.
2020-10-22 06:26:44 +02:00
* `EvalAltResult::ErrorRuntime` now wraps a `Dynamic` instead of a string.
* Default call stack depth for `debug` builds is reduced to 8 (from 12) because it keeps overflowing the stack in GitHub CI!
* Keyword `thread` is reserved.
2020-10-17 10:34:07 +02:00
2020-10-18 15:47:34 +02:00
New features
------------
* The plugins system is enhanced to support functions taking a `NativeCallContext` as the first parameter.
2020-10-20 17:16:03 +02:00
* `throw` statement can now throw any value instead of just text strings.
* New `try` ... `catch` statement to catch exceptions.
2020-10-18 15:47:34 +02:00
2020-10-17 12:18:29 +02:00
Enhancements
2020-10-18 15:47:34 +02:00
------------
2020-10-17 12:18:29 +02:00
* Calling `eval` or `Fn` in method-call style, which is an error, is now caught during parsing.
2020-10-22 06:26:44 +02:00
* `func!()` call style is valid even under `no_closure` feature.
2020-10-17 12:18:29 +02:00
2020-10-17 07:49:16 +02:00
Version 0.19.2
==============
Bug fix on call module functions.
2020-10-16 11:32:26 +02:00
Version 0.19.1
2020-10-01 17:31:27 +02:00
==============
2020-10-16 11:32:26 +02:00
This version adds a variable resolver with the ability to short-circuit variable access,
plus a whole bunch of array methods.
2020-10-12 17:17:22 +02:00
2020-10-01 17:31:27 +02:00
Breaking changes
----------------
2020-10-02 17:14:33 +02:00
* `AST::iter_functions` now returns an iterator instead of taking a closure.
2020-10-05 12:07:40 +02:00
* `Module::get_script_function_by_signature` renamed to `Module::get_script_fn` and returns `&<Shared<ScriptFnDef>>` .
2020-10-05 15:52:39 +02:00
* `Module::num_fn` , `Module::num_var` and `Module::num_iter` are removed and merged into `Module::count` .
2020-10-03 05:42:54 +02:00
* The `merge_namespaces` parameter to `Module::eval_ast_as_new` is removed and now defaults to `true` .
* `GlobalFileModuleResolver` is removed because its performance gain over the `FileModuleResolver` is no longer very significant.
2020-10-05 07:45:57 +02:00
* The following `EvalAltResult` variants are removed and merged into `EvalAltResult::ErrorMismatchDataType` : `ErrorCharMismatch` , `ErrorNumericIndexExpr` , `ErrorStringIndexExpr` , `ErrorImportExpr` , `ErrorLogicGuard` , `ErrorBooleanArgMismatch`
2020-10-09 07:23:44 +02:00
* `Scope::iter_raw` returns an iterator with an additional field indicating whether the variable is constant or not.
2020-10-10 07:43:14 +02:00
* `rhai::ser` and `rhai::de` namespaces are merged into `rhai::serde` .
2020-10-10 16:14:10 +02:00
* New reserved symbols: `++` , `--` , `..` , `...` .
2020-10-11 15:58:11 +02:00
* Callback signature for custom syntax implementation function is changed to allow for more flexibility.
2020-10-12 17:17:22 +02:00
* Default call stack depth for `debug` builds is reduced to 12 (from 16).
2020-10-13 10:01:42 +02:00
* Precedence for `~` is raised, while `in` is moved below logic comparison operators.
2020-10-01 17:31:27 +02:00
2020-10-03 10:25:58 +02:00
New features
------------
2020-10-11 15:58:11 +02:00
* New `Engine::on_var` to register a _variable resolver_ .
2020-10-09 05:15:25 +02:00
* `const` statements can now take any expression (or none at all) instead of only constant values.
2020-10-05 04:27:31 +02:00
* `OptimizationLevel::Simple` now eagerly evaluates built-in binary operators of primary types (if not overloaded).
2020-10-12 17:17:22 +02:00
* `is_def_var()` to detect if variable is defined, and `is_def_fn()` to detect if script function is defined.
2020-10-06 15:25:05 +02:00
* `Dynamic::from(&str)` now constructs a `Dynamic` with a copy of the string as value.
2020-10-07 06:11:25 +02:00
* `AST::combine` and `AST::combine_filtered` allows combining two `AST` 's without creating a new one.
2020-10-13 08:39:49 +02:00
* `map` , `filter` , `reduce` , `reduce_rev` , `some` , `all` , `extract` , `splice` , `chop` and `sort` functions for arrays.
2020-10-16 11:32:26 +02:00
* New `Module::set_iterable` and `Module::set_iterator` to define type iterators more easily. `Engine::register_iterator` is changed to use the simpler version.
2020-10-03 10:25:58 +02:00
2020-10-08 16:25:50 +02:00
Enhancements
------------
* Many one-liners and few-liners are now marked `#[inline]` or `[inline(always)]` , just in case it helps when LTO is not turned on.
2020-10-01 17:31:27 +02:00
2020-08-31 05:23:11 +02:00
Version 0.19.0
==============
2020-09-28 16:14:19 +02:00
The major new feature for this version is _Plugins_ support, powered by procedural macros.
Plugins make it extremely easy to develop and register Rust functions with an `Engine` .
2020-09-15 06:21:51 +02:00
Bug fixes
---------
* `if` statement with an empty `true` block would not evaluate the `false` block. This is now fixed.
* Fixes a bug in `Module::set_fn_4_mut` .
2020-09-20 04:50:58 +02:00
* Module API's now properly handle `&str` and `String` parameters.
* Indexers are available under `no_object` .
2020-09-21 10:15:52 +02:00
* Registered operator-assignment functions (e.g. `+=` ) now work correctly.
2020-09-15 06:21:51 +02:00
2020-09-22 06:14:26 +02:00
Breaking changes
----------------
* `Engine::register_set_result` and `Engine::register_indexer_set_result` now take a function that returns `Result<(), Box<EvalAltResult>>` .
2020-09-28 16:14:19 +02:00
* `Engine::register_indexer_XXX` and `Module::set_indexer_XXX` panic when the type is `Array` , `Map` or `String` .
2020-09-25 12:07:39 +02:00
* `EvalAltResult` has a new variant `ErrorInModule` which holds errors when loading an external module.
* `Module::eval_ast_as_new` now takes an extra boolean parameter, indicating whether to encapsulate the entire module into a separate namespace.
2020-09-28 16:14:19 +02:00
* Functions in `FileModuleResolver` loaded modules now can cross-call each other in addition to functions in the global namespace. For the old behavior, use `MergingFileModuleResolver` instead.
2020-09-25 14:24:03 +02:00
* New `EvalAltResult::ErrorInModule` variant capturing errors when loading a module from a script file.
2020-09-22 06:14:26 +02:00
2020-08-31 05:23:11 +02:00
New features
------------
* Plugins support via procedural macros.
2020-09-11 16:32:59 +02:00
* Scripted functions are allowed in packages.
2020-09-28 16:14:19 +02:00
* `parse_int` and `parse_float` functions for parsing numbers; `split` function for splitting strings.
2020-09-24 10:10:25 +02:00
* `AST::iter_functions` and `Module::iter_script_fn_info` to iterate functions.
2020-09-28 16:14:19 +02:00
* Functions iteration functions for `AST` and `Module` now take `FnMut` instead of `Fn` .
2020-09-24 16:50:28 +02:00
* New `FileModuleResolver` that encapsulates the entire `AST` of the module script, allowing function cross-calling. The old version is renamed `MergingFileModuleResolver` .
2020-09-28 16:14:19 +02:00
* `+` and `-` operators for timestamps to increment/decrement by seconds.
2020-09-26 10:27:38 +02:00
2020-08-31 05:23:11 +02:00
2020-08-22 16:44:24 +02:00
Version 0.18.3
2020-08-05 17:11:54 +02:00
==============
2020-08-20 10:26:10 +02:00
Bug fixes
---------
2020-08-22 05:08:27 +02:00
* `Engine::compile_expression` , `Engine::eval_expression` etc. no longer parse anonymous functions and closures.
2020-08-22 16:44:24 +02:00
* Imported modules now work inside closures.
2020-08-23 11:46:39 +02:00
* Closures that capture now work under `no_object` .
2020-08-22 05:08:27 +02:00
2020-08-21 15:48:45 +02:00
New features
------------
* Adds `Module::combine_flatten` to combine two modules while flattening to the root level.
Version 0.18.2
==============
2020-08-20 10:26:10 +02:00
Bug fixes
---------
* Fixes bug that prevents calling functions in closures.
2020-11-10 16:26:50 +01:00
* Fixes bug that erroneously consumes the first argument to a namespace-qualified function call.
2020-08-20 10:26:10 +02:00
2020-08-07 05:10:38 +02:00
New features
------------
* Adds `Engine::register_get_result` , `Engine::register_set_result` , `Engine::register_indexer_get_result` , `Engine::register_indexer_set_result` API.
2020-08-14 18:08:00 +02:00
* Adds `Module::combine` to combine two modules.
2020-08-18 17:07:17 +02:00
* `Engine::parse_json` now also accepts a JSON object starting with `#{` .
2020-08-07 05:10:38 +02:00
2020-08-05 17:11:54 +02:00
2020-08-05 16:53:01 +02:00
Version 0.18.1
2020-07-14 02:42:02 +02:00
==============
2020-07-19 11:14:55 +02:00
This version adds:
2020-07-26 12:17:55 +02:00
* 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-08-05 17:11:54 +02:00
* Closures - auto-currying of anonymous functions to capture shared variables from the external scope. Use the `no_closure` feature to disable sharing values and capturing.
2020-08-04 12:39:24 +02:00
* Binding the `this` pointer in a function pointer `call` .
2020-07-30 12:18:28 +02:00
* Capturing call scope via `func!(...)` syntax.
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.
2020-07-17 04:18:07 +02:00
* `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` .
2020-07-22 11:05:13 +02:00
* 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-08-04 10:27:55 +02:00
* Automatic currying of anonymous functions to capture shared variables from the external scope.
2020-07-30 12:18:28 +02:00
* Capturing of the calling scope for function call via the `func!(...)` syntax.
2020-09-20 08:52:38 +02:00
* `Module::set_indexer_get_set_fn` is added as a short-hand of both `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` .
2020-07-29 07:57:17 +02:00
* New `unicode-xid-ident` feature to allow [Unicode Standard Annex #31 ](http://www.unicode.org/reports/tr31/ ) for identifiers.
2020-08-03 06:10:20 +02:00
* `Scope::iter_raw` returns an iterator with a reference to the underlying `Dynamic` value (which may be shared).
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.
2020-07-27 12:10:45 +02:00
* `PackagesCollection::get_fn` , `PackagesCollection::contains_fn` , `Module::get_fn` and `Module::contains_fn` now take an additional `public_only` parameter indicating whether only public functions are accepted.
2020-08-03 06:10:20 +02:00
* The iterator returned by `Scope::iter` now contains a clone of the `Dynamic` value (unshared).
2020-12-22 16:45:14 +01:00
* `Engine::register_global_module` takes any type that is `Into<PackageLibrary>` .
2020-08-05 04:00:20 +02:00
* Error in `Engine::register_custom_syntax` is no longer `Box` -ed.
2020-07-26 12:17:55 +02:00
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.
2020-07-06 06:24:28 +02:00
* 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
------------
2020-07-22 11:05:13 +02:00
* 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` .
2020-07-06 06:24:28 +02:00
* 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-11-10 16:26:50 +01:00
* It is now possible to mutate the first argument of a namespace-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.
2021-01-07 10:30:06 +01:00
The `README` is officially transferred to [The Rhai Book ](https://rhaiscript.github.io/book ).
2020-07-01 16:21:43 +02:00
An online [Playground ](https://alvinhochun.github.io/rhai-demo/ ) is available.
2020-06-20 15:49:45 +02:00
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.
2020-06-27 17:56:24 +02:00
* 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` .
2020-06-30 12:34:58 +02:00
* `AST::retain_functions` is used for another purpose. The old `AST::retain_functions` is renamed to `AST::clear_statements` .
2020-06-20 15:49:45 +02:00
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.
2020-06-30 12:34:58 +02:00
* 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
------------
2021-01-07 10:30:06 +01:00
* [The Rhai Book ](https://rhaiscript.github.io/book ) 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
2020-06-16 17:49:11 +02:00
-------
* `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` .
2020-06-12 12:04:16 +02:00
* 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` .
2020-06-12 13:54:55 +02:00
* `Engine::call_fn_dynamic` now takes any type that implements `IntoIterator<Item = Dynamic>` .
2020-06-06 07:06:00 +02:00
New features
------------
2020-09-20 08:52:38 +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 short-hand. Similarly, `Module::set_indexer_get_fn` and `Module::set_indexer_set_fn` are added.
2020-06-07 11:54:33 +02:00
* `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-05-18 13:32:22 +02:00
==============
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.
2020-05-30 04:28:17 +02:00
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.
2020-06-01 08:28:39 +02:00
* `if` expressions are not supposed to be allowed when compiling for expressions only. This is fixed.
2020-05-30 04:28:17 +02:00
2020-05-23 12:59:28 +02:00
Breaking changes
----------------
* `Engine::compile_XXX` functions now return `ParseError` instead of `Box<ParseError>` .
2020-06-01 08:28:39 +02:00
* 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.
2020-06-01 08:28:39 +02:00
* 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
2020-05-18 13:32:22 +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` .
2020-05-30 04:28:17 +02:00
* `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-18 13:32:22 +02:00
2020-05-23 18:29:06 +02:00
Speed enhancements
------------------
2020-06-01 08:28:39 +02:00
* 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.
2020-06-01 08:28:39 +02:00
* 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 13:32:22 +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
------------
2020-06-01 08:28:39 +02:00
* 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.
2020-06-01 08:28:39 +02:00
* 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.