2020-05-18 03:36:34 +02:00
Rhai Release Notes
==================
2022-08-21 16:59:49 +02:00
Version 1.10.0
==============
2022-08-27 11:28:59 +02:00
The minimum Rust version is now `1.61.0` in order to use some `const` generics.
2022-08-21 16:59:49 +02:00
Bug fixes
---------
* API for registering property getters/setters and indexers to an `Engine` now works with functions that take a first parameter of `NativeCallContext` .
2022-08-21 18:15:00 +02:00
* Missing API function `Module::set_getter_setter_fn` is added.
2022-08-26 05:23:16 +02:00
* To avoid subtle errors, simple optimization is used for `rhai-run` ; previous it was full optimization.
2022-08-21 16:59:49 +02:00
2022-08-22 16:16:26 +02:00
Deprecated API
--------------
* All versions of the `Engine::register_XXX_result` API that register a function returning `Result<T, Box<EvalAltResult>>` are now deprecated. The regular, non-`result` versions handle all functions correctly.
2022-08-22 07:10:32 +02:00
New features
------------
2022-08-22 16:16:26 +02:00
### Fallible type iterators
2022-08-22 07:10:32 +02:00
* For very special needs, the ability to register fallible type iterators is added.
2022-08-26 17:10:58 +02:00
### Expressions
* `if` -expressions are allowed in `Engine::eval_expression` and `Engine::compile_expression` provided that both statement blocks each contain at most a single expression.
* `switch` -expressions are allowed in `Engine::eval_expression` and `Engine::compile_expression` provided that match actions are expressions only.
2022-09-03 09:15:42 +02:00
### Fast operators
2022-09-03 06:26:55 +02:00
2022-09-03 09:15:42 +02:00
* A new option `Engine::fast_operators` is introduced that short-circuits all built-in operators of built-in types for higher speed. User overloads are ignored. For operator-heavy scripts, this may yield substantial speed-up's.
2022-09-03 06:26:55 +02:00
2022-08-24 15:58:08 +02:00
Enhancements
------------
* `is_empty` method is added to arrays, BLOB's, object maps, strings and ranges.
2022-08-25 16:17:01 +02:00
* `StaticModuleResolver` now stores the path in the module's `id` field.
2022-08-25 16:25:41 +02:00
* `Engine::module_resolver` is added to grant access to the `Engine` 's module resolver.
2022-08-24 15:58:08 +02:00
2022-08-21 16:59:49 +02:00
2022-08-29 16:26:07 +02:00
Version 1.9.1
=============
This is a bug-fix version that fixes a bug.
Accessing properties in _Strict Variables Mode_ no longer generates a _variable not found_ error.
2022-07-04 11:42:24 +02:00
Version 1.9.0
=============
2022-07-13 13:21:13 +02:00
The minimum Rust version is now `1.60.0` in order to use the `dep:` syntax for dependencies.
2022-07-18 17:28:12 +02:00
Bug fixes
---------
* `switch` cases with conditions that evaluate to constant `()` no longer optimize to `false` (should raise a type error during runtime).
2022-07-20 15:17:21 +02:00
* Fixes concatenation of BLOB's and strings, where the BLOB's should be interpreted as UTF-8 encoded strings.
2022-07-29 03:43:40 +02:00
* Capturing an unknown variable in a closure no longer panics.
2022-07-29 04:49:03 +02:00
* Fixes panic in interpolated strings with constant expressions.
2022-08-09 15:35:45 +02:00
* Using `call_fn_raw` on a function without evaluating the AST no longer panics on namespace-qualified function calls due to `import` statements not run.
2022-08-20 15:55:00 +02:00
* Some reserved tokens (such as "?", "++") cannot be used in custom syntax; this is now fixed.
2022-07-18 17:28:12 +02:00
2022-08-20 09:04:17 +02:00
Breaking changes
----------------
* The first closure passed to `Engine::register_debugger` now takes a single parameter which is a reference to the current `Engine` .
2022-07-05 16:59:03 +02:00
New features
------------
2022-08-12 03:59:48 +02:00
### New feature flags
2022-07-26 16:38:40 +02:00
2022-08-12 03:59:48 +02:00
* A new feature flag, `std` , which is enabled by default, is added due to requirements from dependency crates.
2022-07-26 16:38:40 +02:00
* A new feature flag, `no_custom_syntax` , is added to remove custom syntax support from Rhai for applications that do not require it (which should be most).
### Module documentation
2022-07-25 07:40:23 +02:00
* Comment lines beginning with `//!` (requires the `metadata` feature) are now collected as the script file's _module documentation_ .
2022-07-25 11:42:15 +02:00
* `AST` and `Module` have methods to access and manipulate documentation.
2022-07-05 16:59:03 +02:00
2022-07-26 16:38:40 +02:00
### Output definition files
* An API is added to automatically generate definition files from a fully-configured `Engine` , for use with the Rhai Language Server.
2022-08-05 17:30:44 +02:00
### Short-hand to function pointers
* Using a script-defined function's name (in place of a variable) implicitly creates a function pointer to the function.
2022-08-08 03:10:15 +02:00
### Top-level functions
* Crate-level functions `rhai::eval` , `rhai::run` , `rhai::eval_file` , `rhai::run_file` are added as convenient wrappers.
2022-08-09 15:35:45 +02:00
### CustomType trait and TypeBuilder
* A new volatile API, `Engine::build_type` , enables registration of the entire API of a custom type in one go, provided that the custom type implements the `CustomType` trait (which uses `TypeBuilder` to register the API functions).
2022-08-18 11:22:56 +02:00
### Simpler Package API
* It is now easier to register packages via the `Package::register_into_engine` and `Package::register_into_engine_as` API.
* Defining a custom package with base packages is also much easier with a new syntax - put the new base packages after a colon.
2022-07-04 11:42:24 +02:00
Enhancements
------------
2022-07-18 07:40:41 +02:00
### `switch` statement
2022-07-04 11:42:24 +02:00
* `switch` cases can now include multiple values separated by `|` .
2022-07-18 07:40:41 +02:00
* Duplicated `switch` cases are now allowed.
* The error `ParseErrorType::DuplicatedSwitchCase` is deprecated.
* Ranges in `switch` statements that are small (currently no more than 16 items) are unrolled if possible.
### Others
2022-07-06 06:56:15 +02:00
* `EvalContext::eval_expression_tree_raw` and `Expression::eval_with_context_raw` are added to allow for not rewinding the `Scope` at the end of a statements block.
2022-07-17 06:09:19 +02:00
* A new `range` function variant that takes an exclusive range with a step.
2022-07-20 15:17:21 +02:00
* `as_string` is added to BLOB's to convert it into a string by interpreting it as a UTF-8 byte stream.
2022-07-21 03:36:11 +02:00
* `FnAccess::is_private` , `FnAccess::is_public` , `FnNamespace::is_module_namespace` and `FnNameSpace::is_global_namespace` are added for convenience.
2022-07-26 08:46:34 +02:00
* `Iterator<Item=T>` type for functions metadata is simplified to `Iterator<T>` .
2022-07-27 05:35:40 +02:00
* `Scope::remove` is added to remove a variable from a `Scope` , returning its value.
2022-07-27 10:04:24 +02:00
* The code base is cleaner by running it through Clippy.
2022-07-29 03:42:30 +02:00
* `ParseError::err_type` and `ParseError::position` are added for convenience.
2022-08-14 12:22:07 +02:00
* The source of an `AST` compiled from a script file is set to the file's path.
2022-08-18 10:59:54 +02:00
* `|>` and `<|` are now reserved symbols.
2022-07-04 11:42:24 +02:00
2022-05-05 15:34:15 +02:00
Version 1.8.0
=============
Bug fixes
---------
* Self-contained `AST` now works properly with `Engine::call_fn` .
2022-05-09 08:20:33 +02:00
* Missing `to_int` from `Decimal` is added.
2022-05-17 05:06:34 +02:00
* Parsing of index expressions is relaxed and many cases no longer result in an index-type error to allow for custom indexers.
2022-05-21 05:57:23 +02:00
* Merging or combining a self-contained `AST` into another `AST` now works properly.
2022-06-05 12:07:20 +02:00
* Plugin modules/functions no longer generate errors under `#![deny(missing_docs)]` .
2022-06-07 05:31:46 +02:00
* Calling a property on a function call that returns a shared value no longer causes an error.
2022-06-09 11:59:28 +02:00
* _Strict Variables Mode_ now checks for module namespaces within functions as well.
* Module defined via `Engine::register_static_module` are now checked in _Strict Variables Mode_ .
2022-05-05 15:34:15 +02:00
2022-06-10 02:47:22 +02:00
Reserved Symbols
----------------
2022-06-11 18:32:12 +02:00
* `?` , `??` , `?.` , `?[` and `!.` are now reserved symbols.
2022-06-10 02:47:22 +02:00
2022-05-05 16:30:55 +02:00
Deprecated API's
----------------
* `FnPtr::num_curried` is deprecated in favor of `FnPtr::curry().len()` .
2022-06-10 04:26:06 +02:00
New features
------------
2022-06-11 18:32:12 +02:00
* The _Elvis operators_ (`?.` and `?[` ) are now supported for property access, method calls and indexing.
2022-06-10 05:22:33 +02:00
* The _null-coalescing operator_ (`??`) is now supported to short-circuit `()` values.
2022-06-10 04:26:06 +02:00
2022-05-19 04:02:12 +02:00
Enhancements
------------
2022-06-08 03:19:21 +02:00
* Indexing and property access are now faster.
2022-05-19 04:02:12 +02:00
* `EvalAltResult::IndexNotFound` is added to aid in raising errors for indexers.
2022-05-21 15:44:12 +02:00
* `Engine::def_tag` , `Engine::def_tag_mut` and `Engine::set_tag` are added to manage a default value for the custom evaluation state, accessible via `EvalState::tag()` (which is the same as `NativeCallContext::tag()` ).
* Originally, the debugger's custom state uses the same state as `EvalState::tag()` (which is the same as `NativeCallContext::tag()` ). It is now split into its own variable accessible under `Debugger::state()` .
2022-05-23 16:58:15 +02:00
* Non-borrowed string keys can now be deserialized for object maps via `serde` .
2022-05-24 10:05:17 +02:00
* `Scope::get` is added to get a reference to a variable's value.
2022-06-26 11:04:08 +02:00
* Variable resolvers can now return a _shared_ value which can be mutated.
2022-05-19 04:02:12 +02:00
2022-05-05 15:34:15 +02:00
2022-04-11 10:53:44 +02:00
Version 1.7.0
=============
2022-04-14 16:55:39 +02:00
Bug fixes
---------
* Compound assignments now work properly with indexers.
2022-04-23 05:53:17 +02:00
* Cloning a `Scope` no longer turns all constants to mutable.
2022-04-14 16:55:39 +02:00
2022-04-21 07:21:53 +02:00
Script-breaking changes
-----------------------
2022-04-22 06:12:36 +02:00
* _Strict Variables Mode_ no longer returns an error when an undeclared variable matches a variable/constant in the provided external `Scope` .
2022-04-21 07:21:53 +02:00
2022-05-03 15:55:08 +02:00
Potentially breaking API changes
--------------------------------
2022-05-01 18:03:45 +02:00
* The `Engine::on_var` and `Engine::on_parse_token` API's are now marked unstable/volatile.
* The closures passed to `Engine::on_var` , `Engine::on_def_var` and `Engine::register_debugger` take `EvalContext` instead of `&EvalContext` or `&mut EvalContext` .
2022-05-03 15:55:08 +02:00
* The following enum's are marked `non_exhaustive` : `AccessMode` , `FnAccess` , `FnNamespace` , `FnMetadata` , `OptimizationLevel`
2022-05-01 18:03:45 +02:00
2022-04-26 10:36:24 +02:00
New API
-------
* `Module::eval_ast_as_new_raw` is made public as a low-level API.
* `format_map_as_json` is provided globally, which is the same as `to_json` for object maps.
* `Engine::call_fn_raw_raw` is added to add speed to repeated function calls.
* `Engine::eval_statements_raw` is added to evaluate a sequence of statements.
2022-05-01 18:03:45 +02:00
New features
------------
* A custom state is provided that is persistent during the entire evaluation run. This custom state is a `Dynamic` , which can hold any data, and can be accessed by the host via `EvalContext::tag` , `EvalContext::tag_mut` , `NativeCallContext::tag` and `GlobalRuntimeState.tag` .
2022-04-19 02:28:59 +02:00
Enhancements
------------
2022-04-19 15:45:11 +02:00
* Improper `switch` case condition syntax is now caught at parse time.
2022-04-21 04:04:57 +02:00
* `Engine::parse_json` now natively handles nested JSON inputs (using a token remap filter) without needing to replace `{` with `#{` .
2022-04-21 06:15:21 +02:00
* `to_json` is added to object maps to cheaply convert it to JSON format (`()` is mapped to `null` , all other data types must be supported by JSON)
2022-04-22 07:39:51 +02:00
* `FileModuleResolver` now accepts a custom `Scope` to provide constants for optimization.
2022-04-26 10:36:24 +02:00
* New variants, `Start` and `End` , are added to `DebuggerEvent` triggered at the start/end of script evaluation.
2022-04-19 02:28:59 +02:00
2022-04-11 10:53:44 +02:00
2022-04-11 10:32:23 +02:00
Version 1.6.1
2022-04-08 05:27:52 +02:00
=============
Bug fixes
---------
* Functions with `Dynamic` parameters now work in qualified calls from `import` ed modules.
2022-04-11 10:32:23 +02:00
* `rhai-repl` now compiles with the new patch version of `rustyline` .
2022-04-11 10:53:44 +02:00
* `rhai_codegen` dependency is now explicitly `1.4` or higher.
2022-04-08 05:27:52 +02:00
2022-04-09 07:07:42 +02:00
Script-breaking changes
-----------------------
* `split` now splits a string by whitespaces instead of splitting it into individual characters. This is more in line with common practices.
* A new function `to_chars` for strings is added to split the string into individual characters.
2022-04-09 07:37:43 +02:00
Enhancements
------------
2022-04-11 10:32:23 +02:00
* Strings are now directly iterable (via `for .. in` ) yielding individual characters.
2022-04-09 07:37:43 +02:00
2022-04-08 05:27:52 +02:00
2022-02-18 04:05:58 +01:00
Version 1.6.0
=============
2022-03-30 02:06:19 +02:00
This version, in particular, fixes a plugin macro hygiene error for the nightly compiler:
```text
error[E0425]: cannot find value `args` in this scope
```
2022-02-24 01:54:37 +01:00
Compiler version
----------------
* Minimum compiler version is now `1.57` due to [`smartstring` ](https://crates.io/crates/smartstring ) dependency.
2022-02-18 04:05:58 +01:00
Bug fixes
---------
2022-03-30 02:06:19 +02:00
* Fixed macro hygiene error with nightly compiler.
2022-02-18 04:05:58 +01:00
* Invalid property or method access such as `a.b::c.d` or `a.b::func()` no longer panics but properly returns a syntax error.
2022-02-18 12:13:09 +01:00
* `Scope::is_constant` now returns the correct value.
2022-02-24 04:24:31 +01:00
* Exporting a variable that contains a local function pointer (including anonymous function or closure) now raises a runtime error.
2022-03-04 05:22:44 +01:00
* Full optimization is now skipped for method calls.
2022-02-18 04:05:58 +01:00
2022-03-20 14:58:43 +01:00
New features
------------
* [Type aliases ](https://doc.rust-lang.org/reference/items/type-aliases.html ) in plugin modules are now used as friendly names for custom types. This makes plugin modules more self-contained when they are used to define a custom type's API.
2022-02-18 08:04:46 +01:00
Enhancements
------------
* Variable definitions are optimized so that shadowed variables are reused as much as possible to reduce memory consumption.
2022-02-25 01:38:03 +01:00
* `FnAccess` and `FnNamespace` now implement `Ord` and `PartialOrd` .
2022-02-27 15:47:13 +01:00
* The `event_handler_map` example is enhanced to prevent shadowing of the state object map.
2022-03-05 05:06:47 +01:00
* Separation of constants in function calls is removed as its performance benefit is dubious.
2022-03-08 11:26:32 +01:00
* A function `sleep` is added to block the current thread by a specified number of seconds.
2022-03-09 02:25:32 +01:00
* `Scope::set_alias` is added to export a variable under a particular alias name.
2022-03-23 07:28:45 +01:00
* `starts_with` and `ends_with` are added for strings.
2022-03-27 15:49:34 +02:00
* Variables in modules registered via `register_global_module` can now be accessed in the global namespace.
* `Dynamic::into_read_only` is added to convert a `Dynamic` value into constant.
2022-03-29 02:18:20 +02:00
* `Module` now holds a collection of custom types with an API.
2022-02-18 08:04:46 +01:00
2022-02-18 04:05:58 +01:00
2022-01-24 10:04:40 +01:00
Version 1.5.0
=============
2022-01-29 06:37:58 +01:00
This version adds a debugging interface, which can be used to integrate a debugger.
2022-02-15 04:38:35 +01:00
Based on popular demand, an option is added to throw exceptions when invalid properties are accessed on object maps (default is to return `()` ).
2022-02-09 06:12:43 +01:00
2022-02-15 04:38:35 +01:00
Also based on popular demand, the `REPL` tool now uses a slightly-enhanced version of [`rustyline` ](https://crates.io/crates/rustyline ) for line editing and history.
2022-02-09 01:00:05 +01:00
2022-01-26 15:15:19 +01:00
Bug fixes
---------
* In `Scope::clone_visible` , constants are now properly cloned as constants.
2022-01-29 04:09:43 +01:00
* Variables introduced inside `try` blocks are now properly cleaned up upon an exception.
* Off-by-one error in character positions after a comment line is now fixed.
2022-01-30 10:27:13 +01:00
* Globally-defined constants are now encapsulated correctly inside a loaded module and no longer spill across call boundaries.
2022-02-03 16:54:53 +01:00
* Type names display is fixed.
2022-02-08 12:02:40 +01:00
* Exceptions thrown inside function calls now unwrap correctly when `catch` -ed.
2022-02-09 06:12:43 +01:00
* Error messages for certain invalid property accesses are fixed.
2022-01-26 15:15:19 +01:00
2022-01-28 03:11:40 +01:00
Script-breaking changes
-----------------------
2022-02-03 14:17:47 +01:00
* For consistency with the `import` statement, the `export` statement no longer exports multiple variables.
2022-02-12 16:39:07 +01:00
* Appending a BLOB to a string (via `+` , `+=` , `append` or string interpolation) now treats the BLOB as a UTF-8 encoded string.
* Appending a string/character to a BLOB (via `+=` or `append` ) now adds the string/character as a UTF-8 encoded byte stream.
2022-01-28 03:11:40 +01:00
2022-01-24 10:04:40 +01:00
New features
------------
* A debugging interface is added.
* A new bin tool, `rhai-dbg` (aka _The Rhai Debugger_ ), is added to showcase the debugging interface.
2022-02-02 07:47:35 +01:00
* A new package, `DebuggingPackage` , is added which contains the `back_trace` function to get the current call stack anywhere in a script.
2022-02-09 06:12:43 +01:00
* `Engine::set_fail_on_invalid_map_property` is added to control whether to raise an error (new `EvalAltResult::ErrorPropertyNotFound` ) when invalid properties are accessed on object maps.
2022-02-04 06:20:47 +01:00
* `Engine::set_allow_shadowing` is added to allow/disallow variables _shadowing_ , with new errors `EvalAltResult::ErrorVariableExists` and `ParseErrorType::VariableExists` .
2022-02-13 11:46:25 +01:00
* `Engine::on_def_var` allows registering a closure which can decide whether a variable definition is allow to continue, during compilation or runtime, or should fail with an error (`ParseErrorType::ForbiddenVariable` or `EvalAltResult::ErrorForbiddenVariable` ).
2022-02-10 05:33:48 +01:00
* A new syntax for defining custom packages is introduced that removes the need to specify the Rhai crate name (internally uses the `$crate` meta variable).
2022-01-24 10:04:40 +01:00
2022-01-24 09:06:41 +01:00
Enhancements
------------
2022-01-27 01:22:20 +01:00
* Default features for dependencies (such as `ahash/std` and `num-traits/std` ) are no longer required.
2022-01-29 04:09:43 +01:00
* The `no_module` feature now eliminates large sections of code via feature gates.
2022-01-31 14:02:36 +01:00
* Debug display of `AST` is improved.
2022-02-02 07:47:35 +01:00
* `NativeCallContext::call_level()` is added to give the current nesting level of function calls.
2022-02-03 14:17:47 +01:00
* A new feature, `bin-features` , pulls in all the required features for `bin` tools.
2022-02-04 05:04:33 +01:00
* `AST` position display is improved:
* `Expr::start_position` is added to give the beginning of the expression (not the operator's position).
* `StmtBlock` and `Stmt::Block` now keep the position of the closing `}` as well.
2022-02-08 12:02:40 +01:00
* `EvalAltResult::unwrap_inner` is added to access the base error inside multiple layers of wrappings (e.g. `EvalAltResult::ErrorInFunction` ).
2022-02-10 05:33:48 +01:00
* Yet another new syntax is introduced for `def_package!` that further simplifies the old syntax.
2022-02-12 16:39:07 +01:00
* A new method `to_blob` is added to convert a string into a BLOB as UTF-8 encoded bytes.
* A new method `to_array` is added to convert a BLOB into array of integers.
2022-01-31 14:02:36 +01:00
REPL tool changes
-----------------
The REPL bin tool, `rhai-rpl` , has been enhanced.
### Build changes
* The `rustyline` feature is now required in order to build `rhai-repl` .
* Therefore, `rhai-repl` is no longer automatically built when using a simple `cargo build` with default features.
### Line editor
2022-02-08 15:16:12 +01:00
* `rhai-repl` now uses a modified version of [`rustyline` ](https://crates.io/crates/rustyline ) as a line editor with history.
* Ctrl-Enter can now be used to enter multiple lines without having to attach the `\` continuation character the end of each line.
* Bracketed paste is supported, even on Windows (version 10 or above), so pasting code directly into `rhai-repl` is made much more convenient.
2022-01-31 14:02:36 +01:00
### New commands
* `strict` to turn on/off _Strict Variables Mode_ .
* `optimize` to turn on/off script optimization.
* `history` to print lines history.
2022-02-08 15:16:12 +01:00
* `!!` , `!` _num_, `!` _text_ and `!?` _text_ to recall a history line.
2022-01-31 14:02:36 +01:00
* `keys` to print all key bindings.
2022-01-24 01:34:21 +01:00
2022-01-23 14:49:46 +01:00
2022-01-23 14:09:37 +01:00
Version 1.4.1
2022-01-13 11:13:27 +01:00
=============
2022-01-23 14:49:46 +01:00
This is primarily a bug-fix version which fixes a large number of bugs.
2022-01-13 11:13:27 +01:00
Bug fixes
---------
2022-01-23 14:09:37 +01:00
* Expressions such as `x = x + 1` no longer panics.
2022-01-13 15:05:07 +01:00
* Padding arrays with another array via `pad` no longer loops indefinitely.
2022-01-14 03:04:24 +01:00
* `chop` for arrays and BLOB's now works properly.
2022-01-13 11:13:27 +01:00
* `set_bit` for bit-flags with negative index now works correctly.
2022-01-13 11:13:38 +01:00
* Misnamed `params` field `name` in the JSON output of `Engine::gen_fn_metadata_to_json` is fixed (was incorrectly named `type` ).
2022-01-15 03:18:16 +01:00
* Fixes a potential `unsafe` violation in `for` loop.
2022-01-15 16:34:38 +01:00
* Missing `to_hex` , `to_octal` and `to_binary` for `i128` and `u128` are added.
* `remove` for arrays and BLOB's now treat negative index correctly.
* `parse_int` now works properly for negative numbers.
2022-01-17 16:15:22 +01:00
* `Engine::gen_fn_signatures` now generates signatures for external packages registered via `Engine::register_global_module` .
2022-01-17 16:15:51 +01:00
* `\r\n` pairs are now recognized correctly for doc-comments.
2022-01-13 11:13:27 +01:00
2022-01-13 15:51:10 +01:00
Enhancements
------------
* Formatting of return types in functions metadata info is improved.
2022-01-15 04:26:43 +01:00
* Use `SmartString` for `Scope` variable names and remove `unsafe` lifetime casting.
2022-01-15 16:34:38 +01:00
* Functions in the standard library now have doc-comments (which can be obtained via `Engine::gen_fn_metadata_to_json` ).
2022-01-17 03:21:03 +01:00
* `get` and `set` methods are added to arrays, BLOB's, object maps and strings.
2022-01-13 15:51:10 +01:00
2022-01-13 11:13:27 +01:00
2021-12-15 05:06:17 +01:00
Version 1.4.0
=============
This version adds support for integer _ranges_ via the `..` and `..=` operators.
2021-12-15 15:12:51 +01:00
Many standard API's are extended with range parameters where appropriate.
2021-12-15 05:06:17 +01:00
2021-12-24 07:59:14 +01:00
Script-breaking changes
-----------------------
* `is` is (pun intended) now a reserved keyword to prepare for possible future type checking expressions (e.g. `x is "string"` ).
2022-01-03 16:10:20 +01:00
Breaking changes
----------------
* `LogicPackage` is removed from `CorePackage` .
* Bit-field functions are moved into a new `BitFieldPackage` (used to be in `LogicPackage` ) which makes more sense.
2022-01-05 06:24:52 +01:00
Bug fixes
---------
2022-01-11 02:05:18 +01:00
* Custom syntax now works properly inside binary expressions and with method calls.
* Hex numbers with the high-bit set now parse correctly into negative integer numbers.
2022-01-05 06:24:52 +01:00
* Constructing a literal array or object map now checks for size limits for each item instead of at the very end when it is already too late.
* Non-`INT` integer types are now treated exactly as custom types under `only_i64` and `only_i32` .
2022-01-06 08:30:17 +01:00
* Calling `pad` on an array now checks for total size over limit after each item added.
2022-01-05 06:24:52 +01:00
2021-12-15 05:06:17 +01:00
New features
------------
* Added support for integer _ranges_ via the `..` and `..=` operators.
2022-01-11 04:33:54 +01:00
* Added `EvalAltResult::ErrorCustomSyntax` to catch errors in custom syntax, which should not happen unless an `AST` is compiled on one `Engine` but evaluated on another unrelated `Engine` .
2021-12-15 05:06:17 +01:00
2021-12-18 05:29:04 +01:00
Enhancements
------------
2022-01-11 02:05:18 +01:00
* `BLOB` 's are refined to display in a more compact hex format.
2021-12-20 04:42:39 +01:00
* A new syntax is introduced for `def_package!` that will replace the old syntax in future versions.
2021-12-22 05:41:55 +01:00
* Added `NativeCallContext::call_fn` to easily call a function.
2021-12-21 09:14:07 +01:00
* Doc-comments on plugin module functions are extracted into the functions' metadata.
2021-12-18 05:29:04 +01:00
2021-12-16 11:01:49 +01:00
Deprecated API's
----------------
* `Expression::get_variable_name` is deprecated in favor of the new `Expression::get_string_value` .
2021-12-20 04:42:39 +01:00
* The old syntax of `def_package!` is deprecated in favor of the new syntax.
2021-12-16 11:01:49 +01:00
2021-12-15 05:06:17 +01:00
2021-11-23 05:45:59 +01:00
Version 1.3.0
=============
2021-12-12 09:29:54 +01:00
This version adds native support for `BLOB` 's (byte arrays), as well as a number of configuration
settings to fine-tun language features.
2021-11-25 10:09:00 +01:00
Compiler requirement
--------------------
2021-12-07 12:03:04 +01:00
* Minimum compiler version is now 1.51.
2021-12-02 05:50:11 +01:00
2021-12-12 09:29:54 +01:00
Bug fixes
---------
* `from_dynamic` now supports deserializing `Option` .
2021-12-03 04:16:35 +01:00
New features
------------
2021-12-07 12:03:04 +01:00
* `BLOB` (essentially a byte array) is added as a supported primitive value type parallel to arrays.
2021-12-04 10:57:28 +01:00
* New options for `Engine` which allows disabling `if` -expressions, `switch` -expressions, statement expressions, anonymous functions and/or looping (i.e. `while` , `loop` , `do` and `for` statements):
* `Engine::set_allow_if_expression`
* `Engine::set_allow_switch_expression`
* `Engine::set_allow_statement_expression`
* `Engine::set_allow_anonymous_fn`
* `Engine::set_allow_looping`
* New _strict variables_ mode for `Engine` (enabled via `Engine::set_strict_variables` ) to throw parse errors on undefined variable usage. Two new parse error variants, `ParseErrorType::VariableNotFound` and `ParseErrorType::ModuleNotFound` , are added.
2021-12-03 04:16:35 +01:00
2021-11-23 05:45:59 +01:00
Enhancements
------------
2021-12-09 06:34:51 +01:00
* Two double quotes (`""`) in a string literal now maps to `"` ; two back-ticks (``` `` ```) in a literal string now maps to `` ` ` `.
2021-12-09 05:49:12 +01:00
* Added `Engine::register_type_with_name_raw` to register a custom type based on a fully-qualified type path.
2021-11-23 05:45:59 +01:00
* Added `into_array` and `into_typed_array` for `Dynamic` .
2021-11-29 05:43:59 +01:00
* Added `FnPtr::call` and `FnPtr::call_within_context` to simplify calling a function pointer.
2021-12-12 05:33:22 +01:00
* A function's hashes are included in its JSON metadata to assist in debugging. Each function's `baseHash` field in the JSON object should map directly to the pre-calculated hash in the function call.
2021-12-06 11:50:37 +01:00
* `Expression` now derefs to `Expr` .
2021-11-23 05:45:59 +01:00
2021-11-29 03:58:46 +01:00
Deprecated and Gated API's
--------------------------
2021-11-27 07:24:36 +01:00
2021-11-28 05:41:33 +01:00
* `NativeCallContext::new` is deprecated because it is simpler to call a function pointer via `FnPtr::call` .
2021-11-29 02:43:35 +01:00
* `AST::merge_filtered` and `AST::combine_filtered` are no longer exported under `no_function` .
2021-11-29 03:58:46 +01:00
* `AST::new` and `AST::new_with_source` are moved under `internals` .
2021-11-29 05:43:59 +01:00
* `FnPtr::call_dynamic` is deprecated in favor of `FnPtr::call_raw` .
2021-11-27 07:24:36 +01:00
2021-11-23 05:45:59 +01:00
2021-11-19 08:07:29 +01:00
Version 1.2.1
=============
2021-11-23 15:37:18 +01:00
Bug fixes
---------
* Array methods (such as `map` ) taking a closure with captures as argument now works properly.
2021-11-19 08:07:29 +01:00
2021-10-11 11:57:11 +02:00
Version 1.2.0
=============
2021-12-24 07:59:14 +01:00
Bug fixes (potentially script-breaking)
--------------------------------------
2021-11-14 15:48:57 +01:00
* As originally intended, function calls with a bang (`!`) now operates directly on the caller's scope, allowing variables inside the scope to be mutated.
2021-11-15 07:30:00 +01:00
* As originally intended, `Engine::XXX_with_scope` API's now properly propagate constants within the provided scope also to _functions_ in the script.
2021-11-19 08:04:59 +01:00
* Printing of integral floating-point numbers is fixed (used to only prints `0.0` ).
* `func!()` calls now work properly under `no_closure` .
* Fixed parsing of unary negation such that expressions like `if foo { ... } -x` parses correctly.
2021-11-08 15:16:28 +01:00
2021-10-20 09:30:11 +02:00
New features
------------
* `#[cfg(...)]` attributes can now be put directly on plugin functions or function defined in a plugin module.
2021-10-25 16:41:42 +02:00
* A custom syntax parser can now return a symbol starting with `$$` to inform the implementation function which syntax variant was actually parsed.
2021-11-15 04:13:00 +01:00
* `AST::iter_literal_variables` is added to extract all top-level literal constant/variable definitions from a script without running it.
* `Engine::call_fn_dynamic` is deprecated and `Engine::call_fn_raw` is added which allows keeping new variables in the custom scope.
2021-10-20 09:30:11 +02:00
2021-10-19 13:57:15 +02:00
Enhancements
------------
* Array methods now avoid cloning as much as possible (although most predicates will involve cloning anyway if passed a closure).
2021-10-20 05:06:38 +02:00
* Array methods that take function pointers (e.g. closures) now optionally take the function name as a string.
2021-10-21 11:59:54 +02:00
* Array adds the `dedup` method.
2021-10-23 05:51:48 +02:00
* Array adds a `sort` method with no parameters which sorts homogeneous arrays of built-in comparable types (e.g. `INT` ).
2021-10-19 17:52:58 +02:00
* Inlining is disabled for error-path functions because errors are exceptional and scripts usually fail completely when an error is encountered.
2021-10-21 13:17:34 +02:00
* The `optimize` module is completely eliminated under `no_optimize` , which should yield smaller code size.
2021-11-15 04:13:00 +01:00
* `NativeCallContext::position` is added to return the position of the function call.
* `Scope::clone_visible` is added that copies only the last instance of each variable, omitting all shadowed variables.
2021-10-19 17:52:58 +02:00
Deprecated API's
----------------
* `NativeCallContext::call_fn_dynamic_raw` is deprecated and `NativeCallContext::call_fn_raw` is added.
2021-12-16 09:10:39 +01:00
* `From<EvalAltResult>` for `Result<T, Box<EvalAltResult> >` is deprecated so it will no longer be possible to do `EvalAltResult::ErrorXXXXX.into()` to convert to a `Result` ; instead, `Err(EvalAltResult:ErrorXXXXX.into())` must be used. Code is clearer if errors are explicitly wrapped in `Err` .
2021-10-19 13:57:15 +02:00
2021-10-11 11:57:11 +02:00
2021-11-03 01:44:07 +01:00
Version 1.1.2
=============
Bug fixes
---------
* `0.0` now prints correctly (used to print `0e0` ).
2021-11-03 02:11:20 +01:00
* Unary operators are now properly recognized as an expression statement.
2021-11-08 15:16:28 +01:00
* Reverses a regression on string `+` operations.
* The global namespace is now searched before packages, which is the correct behavior.
2021-11-03 01:44:07 +01:00
2021-10-11 11:56:22 +02:00
Version 1.1.1
=============
2021-10-23 11:49:52 +02:00
Bug fixes
---------
2021-11-01 02:55:50 +01:00
* Assignment to indexing expression with dot expressions inside no longer cause a compilation error.
2021-10-23 11:49:52 +02:00
* The `no_module` and `internals` features now work together without a compilation error.
2021-11-01 02:42:22 +01:00
* String literal operations (such as `"hello" + ", world"` ) now optimizes correctly.
2021-10-23 11:49:52 +02:00
2021-10-11 11:56:22 +02:00
2021-08-11 10:09:04 +02:00
Version 1.1.0
=============
2021-08-13 13:23:20 +02:00
Bug fixes
---------
* Custom syntax starting with a disabled standard keyword now works properly.
2021-08-17 17:24:41 +02:00
* When calling `Engine::call_fn` , new variables defined during evaluation of the body script are removed and no longer spill into the function call.
2021-09-11 13:40:40 +02:00
* `NamespaceRef::new` is fixed.
2021-08-13 13:23:20 +02:00
2021-08-11 10:09:04 +02:00
Enhancements
------------
2021-09-03 15:01:07 +02:00
### `Engine` API
2021-08-06 08:46:27 +02:00
* `Engine::consume_XXX` methods are renamed to `Engine::run_XXX` to make meanings clearer. The `consume_XXX` API is deprecated.
2021-09-03 15:01:07 +02:00
* `Engine::register_type_XXX` are now available even under `no_object` .
2021-09-24 12:00:48 +02:00
* Added `Engine::on_parse_token` to allow remapping certain tokens during parsing.
2021-09-26 15:25:29 +02:00
* Added `Engine::const_empty_string` to merge empty strings into a single instance.
2021-09-03 15:01:07 +02:00
### Custom Syntax
2021-07-10 09:50:31 +02:00
* `$symbol$` is supported in custom syntax to match any symbol.
2021-08-02 04:24:03 +02:00
* Custom syntax with `$block$` , `}` or `;` as the last symbol are now self-terminating (i.e. no need to attach a terminating `;` ).
2021-09-03 15:01:07 +02:00
### `Dynamic` Values
2021-07-24 10:24:59 +02:00
* `Dynamic::as_string` and `Dynamic::as_immutable_string` are deprecated and replaced by `into_string` and `into_immutable_string` respectively.
2021-07-25 05:50:31 +02:00
* Added a number of constants to `Dynamic` .
2021-07-25 16:48:40 +02:00
* Added a number of constants and `fromXXX` constant methods to `Dynamic` .
2021-09-15 04:41:35 +02:00
* Added `sin` , `cos` and `tan` for `Decimal` values.
2021-09-03 15:01:07 +02:00
### `Decimal` Values
2021-08-11 10:09:04 +02:00
* `parse_float()` , `PI()` and `E()` now defer to `Decimal` under `no_float` if `decimal` is turned on.
2021-08-11 12:15:17 +02:00
* Added `log10()` for `Decimal` .
* `ln` for `Decimal` is now checked and won't panic.
2021-09-03 15:01:07 +02:00
2021-09-20 05:34:01 +02:00
### String Values
* `SmartString` now uses `LazyCompact` instead of `Compact` to minimize allocations.
2021-09-20 10:25:23 +02:00
* Added `pop` for strings.
2021-09-27 05:09:19 +02:00
* Added `ImmutableString::ptr_eq` to test if two strings point to the same allocation.
2021-09-28 13:19:17 +02:00
* The `serde` feature of `SmartString` is turned on under `metadata` to make `Map` serializable.
2021-09-20 05:34:01 +02:00
2021-09-03 15:01:07 +02:00
### `Scope` API
2021-12-16 09:10:39 +01:00
* `Scope::set_value` now takes anything that implements `Into<Cow<str> >` .
2021-08-13 16:47:03 +02:00
* Added `Scope::is_constant` to check if a variable is constant.
2021-08-14 08:56:15 +02:00
* Added `Scope::set_or_push` to add a new variable only if one doesn't already exist.
2021-09-03 15:01:07 +02:00
### `AST` API
2021-09-03 14:47:45 +02:00
* Added `ASTNode::position` .
2021-09-10 14:23:59 +02:00
* `ReturnType` is removed in favor of option flags for `Stmt::Return` .
* `Stmt::Break` and `Stmt::Continue` are merged into `Stmt::BreakLoop` via an option flag.
2021-09-10 14:25:22 +02:00
* `StaticVec` is changed to keep three items inline instead of four.
2021-08-11 10:09:04 +02:00
2021-09-19 16:31:50 +02:00
Version 1.0.6
=============
2021-09-27 04:34:24 +02:00
Bug fixes
---------
* Eliminate unnecessary property write-back when accessed via a getter since property getters are assumed to be _pure_ .
2021-09-28 09:59:46 +02:00
* Writing to a property of an indexed valued obtained via an indexer now works properly by writing back the changed value via an index setter.
2021-09-27 04:34:24 +02:00
Enhancements
------------
2021-09-24 03:26:35 +02:00
* `MultiInputsStream` , `ParseState` , `TokenIterator` , `IdentifierBuilder` and `AccessMode` are exported under the `internals` feature.
2021-09-19 16:31:50 +02:00
2021-09-04 12:43:18 +02:00
Version 1.0.5
=============
2021-09-15 04:31:46 +02:00
Bug fixes
---------
2021-09-04 12:43:18 +02:00
* `FloatWrapper` is no longer erroneously exported under `no_float+internals` .
2021-09-15 04:31:46 +02:00
* The `sign` function now works properly for float values that are `NaN` .
2021-09-04 12:43:18 +02:00
2021-09-03 04:19:58 +02:00
Version 1.0.4
2021-09-02 16:49:17 +02:00
=============
2021-09-02 16:17:45 +02:00
* Fixed bug with `catch` variable used in `catch` block.
2021-08-17 09:46:21 +02:00
Version 1.0.2
=============
Bug fixes
---------
* Fixed bug in method call followed by an array indexing.
2021-07-24 06:27:33 +02:00
Version 1.0.1
=============
Bug fixes
---------
* Fixed bug in using indexing/dotting inside index bracket.
2021-08-04 11:37:56 +02:00
* `while` and `loop` statements are no longer considered _pure_ (since a loop can go on forever and this is a side effect).
2021-07-24 06:27:33 +02:00
2021-06-24 05:50:03 +02:00
Version 1.0.0
=============
The official version `1.0` .
2021-06-30 05:08:29 +02:00
Almost the same version as `0.20.3` but with deprecated API's removed.
2021-06-24 05:50:03 +02:00
2021-07-01 06:27:29 +02:00
Bug fixes
---------
* Fixed infinite loop in certain script optimizations.
2021-07-01 12:44:01 +02:00
* Building for `no-std` no longer requires patching `smartstring` .
2021-07-03 18:15:27 +02:00
* Parsing a lone `return` or `throw` without a semicolon at the end of a block no longer raises an error.
2021-07-01 06:27:29 +02:00
2021-06-28 07:53:30 +02:00
Breaking changes
----------------
* All deprecated API's (e.g. the `RegisterFn` and `RegisterResultFn` traits) are removed.
* `Module::set_id` is split into `Module::set_id` and `Module::clear_id` pair.
2021-07-06 03:51:29 +02:00
* `begin` , `end` , `each` , `then` , `unless` are no longer reserved keywords.
2021-06-28 07:53:30 +02:00
2021-06-27 16:10:52 +02:00
Enhancements
------------
* New methods `is_odd` , `is_even` for integers, and `is_zero` for all numbers.
2021-06-30 05:08:29 +02:00
* `From<BTreeSet>` and `From<HashSet>` are added for `Dynamic` , which create object maps with `()` values.
2021-06-27 16:10:52 +02:00
2021-06-24 05:50:03 +02:00
2021-05-29 12:33:29 +02:00
Version 0.20.3
==============
2021-06-22 16:32:50 +02:00
This version adds support to index into an integer number, treating it as a bit-field.
2021-06-02 08:29:18 +02:00
Bug fixes
---------
* Fixed incorrect optimization regarding chain-indexing with non-numeric index.
2021-06-11 13:59:50 +02:00
* Variable values are checked for over-sized violations after assignments and setters.
2021-06-02 08:29:18 +02:00
2021-06-07 03:47:49 +02:00
Breaking changes
----------------
2021-06-22 16:32:50 +02:00
* To keep the API consistent, strings are no longer iterable by default. Use the `chars` method to iterate through the characters in a string.
2021-06-10 04:45:44 +02:00
* `Dynamic::take_string` and `Dynamic::take_immutable_string` are renamed to `Dynamic::as_string` and `Dynamic::as_immutable_string` respectively.
2021-06-07 03:47:49 +02:00
2021-06-02 08:29:18 +02:00
New features
------------
2021-06-07 05:01:16 +02:00
* New syntax for `for` statement to include counter variable.
2021-06-02 08:29:18 +02:00
* An integer value can now be indexed to get/set a single bit.
2021-06-07 03:47:49 +02:00
* The `bits` method of an integer can be used to iterate through its bits.
2021-06-10 04:16:39 +02:00
* New `$bool$` , `$int$` , `$float$` and `$string$` expression types for custom syntax.
2021-06-16 17:49:18 +02:00
* New methods `to_hex` , `to_octal` and `to_binary` for integer numbers.
2021-06-17 07:31:58 +02:00
* New methods `to_upper` , `to_lower` , `make_upper` , `make_lower` for strings/characters.
2021-06-02 08:29:18 +02:00
2021-05-29 12:33:29 +02:00
2021-05-02 14:36:59 +02:00
Version 0.20.2
==============
2021-05-22 13:14:24 +02:00
This version adds a number of convenience features:
* Ability for a `Dynamic` to hold an `i32` _tag_ of arbitrary data
* Simplifies dynamic properties access by falling back to an indexer (passing the name of the property as a string) when a property is not found.
2021-05-15 05:41:42 +02:00
Bug fixes
---------
2021-05-22 13:14:24 +02:00
* Propagation of constants held in a custom scope now works properly instead of always replacing by `()` .
2021-05-15 05:41:42 +02:00
2021-05-03 07:07:51 +02:00
Breaking changes
----------------
* `Engine::disable_doc_comments` is removed because doc-comments are now placed under the `metadata` feature flag.
2021-05-11 04:58:28 +02:00
* Registering a custom syntax now only requires specifying whether the `Scope` is adjusted (i.e. whether variables are added or removed). There is no need to specify the number of variables added/removed.
2021-05-15 05:41:42 +02:00
* Assigning to a property of a constant is now allowed and no longer raise an `EvalAltResult::ErrorAssignmentToConstant` error. This is to facilitate the Singleton pattern. Registered setter functions are automatically guarded against setters calling on constants and will continue to raise errors unless the `pure` attribute is present (for plugins).
2021-05-18 14:12:30 +02:00
* If a property getter/setter is not found, an indexer with string index, if any, is tried.
* The indexers API (`Engine::register_indexer_XXX` and `Module::set_indexer_XXX` ) are now also exposed under `no_index` .
2021-05-03 07:07:51 +02:00
2021-05-02 17:51:37 +02:00
New features
------------
2021-05-18 06:24:11 +02:00
* Each `Dynamic` value can now contain arbitrary data (type `i32` ) in the form of a _tag_ . This is to use up otherwise wasted space in the `Dynamic` type.
2021-05-08 16:59:33 +02:00
* A new internal feature `no_smartstring` to turn off `SmartString` for those rare cases that it is needed.
2021-05-10 05:07:19 +02:00
* `DynamicReadLock` and `DynamicWriteLoc` are exposed under `internals` .
2021-08-11 10:09:04 +02:00
* `From< Shared< Locked<Dynamic> > >` is added for `Dynamic` mapping directly to a shared value, together with support for `Dynamic::from` .
2021-05-18 14:12:30 +02:00
* An indexer with string index acts as a _fallback_ to a property getter/setter.
2021-05-02 17:51:37 +02:00
2021-05-11 04:58:28 +02:00
Enhancements
------------
* Registering a custom syntax now only requires specifying whether the `Scope` is adjusted (i.e. whether variables are added or removed). This allows more flexibility for cases where the number of new variables declared depends on internal logic.
2021-05-15 05:41:42 +02:00
* Putting a `pure` attribute on a plugin property/index setter now enables it to be used on constants.
2021-05-11 04:58:28 +02:00
2021-05-02 17:51:37 +02:00
2021-04-16 16:07:18 +02:00
Version 0.20.1
==============
2021-04-17 11:25:35 +02:00
This version enables functions to access constants declared at global level via the special `global` module.
2021-04-19 09:11:03 +02:00
Bug fixes
---------
* Fixed bug when position is zero in `insert` and `split_at` methods for arrays.
2021-04-24 07:42:30 +02:00
* Indexing operations with pure index values are no longer considered pure due to the possibility of indexers.
2021-04-19 09:11:03 +02:00
2021-04-17 06:03:29 +02:00
Breaking changes
----------------
* `Dynamic::is_shared` and `Dynamic::is_locked` are removed under the `no_closure` feature. They used to always return `false` .
2021-04-17 07:36:23 +02:00
* `Engine::call_fn` now evaluates the `AST` before calling the function.
2021-04-25 09:27:58 +02:00
* `Engine::on_progress` is disabled with `unchecked` .
2021-04-17 06:03:29 +02:00
2021-04-17 11:25:35 +02:00
Enhancements
------------
* The crate [`no-std-compat` ](https://crates.io/crates/no_std_compat ) is used to compile for `no-std` . This removes the need to use a special `crate::stdlib` namespace for `std` imports.
New features
------------
* A module called `global` is automatically created to hold global-level constants, which can then be accessed from functions.
2021-04-22 17:02:25 +02:00
* A new feature `no_position` is added to turn off position tracking during parsing to squeeze out the last drop of performance.
2021-04-17 11:25:35 +02:00
2021-04-16 16:07:18 +02:00
2021-04-16 15:59:11 +02:00
Version 0.20.0
==============
2021-03-31 11:01:08 +02:00
2021-04-10 09:00:03 +02:00
This version adds string interpolation with `` `... ${`` ... ``} ...` `` syntax.
2021-04-16 15:59:11 +02:00
`switch` statement cases can now have conditions.
2021-04-10 09:00:03 +02:00
Negative indices for arrays and strings are allowed and now count from the end (-1 = last item/character).
2021-04-03 05:12:35 +02:00
Bug fixes
---------
* Property setter op-assignments now work properly.
2021-04-10 09:00:03 +02:00
* Off-by-one bug in `Array::drain` method with range is fixed.
2021-04-03 05:12:35 +02:00
2021-04-02 06:34:39 +02:00
Breaking changes
----------------
2021-04-10 09:00:03 +02:00
* Negative index to an array or string yields the appropriate element/character counting from the _end_ .
2021-04-16 07:28:36 +02:00
* The default `_` case of a `switch` statement now must be the last case, together with two new error variants: `EvalAltResult::WrongSwitchDefaultCase` and `EvalAltResult::WrongSwitchCaseCondition` .
2021-04-02 06:34:39 +02:00
* `ModuleResolver` trait methods take an additional parameter `source_path` that contains the path of the current environment. This is to facilitate loading other script files always from the current directory.
* `FileModuleResolver` now resolves relative paths under the source path if there is no base path set.
* `FileModuleResolver::base_path` now returns `Option<&str>` which is `None` if there is no base path set.
2021-04-09 16:49:47 +02:00
* Doc-comments now require the `metadata` feature.
2021-04-02 06:34:39 +02:00
2021-04-10 09:00:03 +02:00
Enhancements
------------
* `Array::drain` and `Array::retain` methods with predicate now scan the array in forward order instead of in reverse.
2021-04-02 06:34:39 +02:00
New features
------------
2021-04-04 07:13:07 +02:00
* String interpolation support is added via the `` `... ${`` ... ``} ...` `` syntax.
2021-04-02 06:34:39 +02:00
* `FileModuleResolver` resolves relative paths under the parent path (i.e. the path holding the script that does the loading). This allows seamless cross-loading of scripts from a directory hierarchy instead of having all relative paths load from the current working directory.
2021-04-10 09:00:03 +02:00
* Negative index to an array or string yields the appropriate element/character counting from the _end_ .
2021-04-16 06:04:33 +02:00
* `switch` statement cases can now have an optional `if` clause.
2021-04-02 06:34:39 +02:00
2021-03-31 11:01:08 +02:00
2021-03-14 15:56:06 +01:00
Version 0.19.15
===============
2021-03-23 13:04:54 +01:00
This version replaces all internal usage of `HashMap` with `BTreeMap` , which should result
in some speed improvement because a `BTreeMap` is leaner when the number of items held is small.
Most, if not all, collections in Rhai hold very few data items, so this is a typical scenario of
many tiny-sized collections.
2021-03-23 05:13:53 +01:00
2021-03-23 13:04:54 +01:00
The Rhai object map type, `Map` , used to be an alias to `HashMap` and is now aliased to `BTreeMap`
instead. This is also because, in the vast majority of usage cases, the number of properties held by
an object map is small.
2021-03-23 05:13:53 +01:00
2021-03-23 13:04:54 +01:00
`HashMap` and `BTreeMap` have almost identical public API's so this change is unlikely to break
existing code.
2021-03-23 05:13:53 +01:00
2021-03-31 11:01:08 +02:00
[`SmartString` ](https://crates.io/crates/smartstring ) is used to store identifiers (which tend to
2021-03-29 18:21:09 +02:00
be short, fewer than 23 characters, and ASCII-based) because they can usually be stored inline.
`Map` keys now also use [`SmartString` ](https://crates.io/crates/smartstring ).
In addition, there is now support for line continuation in strings (put `\` at the end of line) as
2021-03-31 11:01:08 +02:00
well as multi-line literal strings (wrapped by back-ticks: `` `...` ``).
2021-03-29 18:21:09 +02:00
Finally, all function signature/metadata methods are now grouped under the umbrella `metadata` feature.
2021-03-25 12:49:30 +01:00
This avoids spending precious resources maintaining metadata for functions for the vast majority of
use cases where such information is not required.
2021-03-25 07:02:50 +01:00
2021-03-23 05:13:53 +01:00
2021-03-31 04:16:38 +02:00
Bug fixes
---------
* The feature flags `no_index + no_object` now compile without errors.
2021-03-15 04:36:30 +01:00
Breaking changes
----------------
* The traits `RegisterFn` and `RegisterResultFn` are removed. `Engine::register_fn` and `Engine::register_result_fn` are now implemented directly on `Engine` .
* `FnPtr::call_dynamic` now takes `&NativeCallContext` instead of consuming it.
2021-03-15 05:39:06 +01:00
* All `Module::set_fn_XXX` methods are removed, in favor of `Module::set_native_fn` .
2021-03-22 04:18:09 +01:00
* `Array::reduce` and `Array::reduce_rev` now take a `Dynamic` as initial value instead of a function pointer.
2021-03-17 03:31:50 +01:00
* `protected` , `super` are now reserved keywords.
2021-03-24 02:56:25 +01:00
* The `Module::set_fn_XXX` API now take `&str` as the function name instead of `Into<String>` .
2021-03-24 12:27:38 +01:00
* The _reflections_ API such as `Engine::gen_fn_signatures` , `Module::update_fn_metadata` etc. are put under the `metadata` feature gate.
2021-03-28 10:36:56 +02:00
* The shebang `#!` is now a reserved symbol.
* Shebangs at the very beginning of script files are skipped when loading them.
2021-03-31 11:01:08 +02:00
* [`SmartString` ](https://crates.io/crates/smartstring ) is used for identifiers by default. Currently, a PR branch is pulled for `no-std` builds. The official crate will be used once `SmartString` is fixed to support `no-std` .
2021-03-29 18:21:09 +02:00
* `Map` is now an alias to `BTreeMap<SmartString, Dynamic>` instead of `HashMap` because most object maps hold few properties.
2021-03-30 05:39:00 +02:00
* `EvalAltResult::FnWrongDefinition` is renamed `WrongFnDefinition` for consistency.
2021-03-29 18:21:09 +02:00
New features
------------
2022-02-02 15:42:33 +01:00
* Line continuation (via `\` ) and multi-line literal strings (wrapped with `` ` ` `) support are added.
2021-03-29 18:21:09 +02:00
* Rhai scripts can now start with a shebang `#!` which is ignored.
2021-03-15 04:36:30 +01:00
2021-03-15 15:37:50 +01:00
Enhancements
------------
2021-03-23 13:04:54 +01:00
* Replaced all `HashMap` usage with `BTreeMap` for better performance because collections in Rhai are tiny.
2021-03-22 04:18:09 +01:00
* `Engine::register_result_fn` no longer requires the successful return type to be `Dynamic` . It can now be any clonable type.
2021-12-16 09:10:39 +01:00
* `#[rhai_fn(return_raw)]` can now return `Result<T, Box<EvalAltResult> >` where `T` is any clonable
type instead of `Result<Dynamic, Box<EvalAltResult> >` .
2021-03-30 12:57:16 +02:00
* `Dynamic::clone_cast` is added to simplify casting from a `&Dynamic` .
2021-03-15 15:37:50 +01:00
2021-03-14 15:56:06 +01:00
2021-02-27 08:06:57 +01:00
Version 0.19.14
===============
2021-03-11 14:55:55 +01:00
This version runs faster due to optimizations done on AST node structures. It also fixes a number of
panic bugs related to passing shared values as function call arguments.
2021-03-10 05:27:10 +01:00
2021-02-27 08:06:57 +01:00
Bug fixes
---------
2021-03-06 03:44:55 +01:00
* Panic when passing a shared string into a registered function as `&str` argument is fixed.
* Panic when calling `switch` statements on custom types is fixed.
* Potential overflow panics in `range(from, to, step)` is fixed.
2021-03-06 07:41:35 +01:00
* `&mut String` parameters in registered functions no longer panic when passed a string.
2021-03-06 03:44:55 +01:00
* Some expressions involving shared variables now work properly, for example `x in shared_value` , `return shared_value` , `obj.field = shared_value` etc. Previously, the resultant value is still shared which is counter-intuitive.
2021-02-27 08:06:57 +01:00
* Errors in native Rust functions now contain the correct function call positions.
2021-02-28 07:38:34 +01:00
* Fixed error types in `EvalAltResult::ErrorMismatchDataType` which were swapped.
2021-02-27 08:06:57 +01:00
2021-02-27 08:27:40 +01:00
Breaking changes
----------------
2021-03-05 16:00:27 +01:00
* `Dynamic::as_str` is removed because it does not properly handle shared values.
2021-02-27 08:27:40 +01:00
* Zero step in the `range` function now raises an error instead of creating an infinite stream.
2021-02-28 07:38:34 +01:00
* Error variable captured by `catch` is now an _object map_ containing error fields.
* `EvalAltResult::clear_position` is renamed `EvalAltResult::take_position` and returns the position taken.
2021-03-01 08:39:49 +01:00
* `private` functions in an `AST` can now be called with `call_fn` etc.
* `NativeCallContext::call_fn_dynamic_raw` no longer has the `pub_only` parameter.
2021-03-01 08:58:11 +01:00
* `Module::update_fn_metadata` input parameter is changed.
2021-03-01 10:17:13 +01:00
* Function keywords (e.g. `type_of` , `eval` , `Fn` ) can no longer be overloaded. It is more trouble than worth. To disable these keywords, use `Engine::disable_symbol` .
2021-03-01 15:44:56 +01:00
* `is_def_var` and `is_def_fn` are now reserved keywords.
2021-03-09 12:13:26 +01:00
* `Engine::id` field is removed because it is never used.
2021-03-04 16:47:52 +01:00
* `num-traits` is now a required dependency.
2021-03-09 11:11:43 +01:00
* The `in` operator is now implemented on top of the `contains` function and is no longer restricted to a few specific types.
2021-03-09 12:13:26 +01:00
* `EvalAltResult::ErrorInExpr` is removed because the `in` operator now calls `contains` .
2021-03-11 14:55:55 +01:00
* The methods `AST::walk` , `Expr::walk` , `Stmt::walk` and `ASTNode::walk` and the callbacks they take now return `bool` to optionally terminate the recursive walk.
2021-02-27 08:27:40 +01:00
Enhancements
------------
2021-03-10 05:27:10 +01:00
* Layout of AST nodes is optimized to reduce redirections, so speed is improved.
2021-03-02 07:44:21 +01:00
* Function calls are more optimized and should now run faster.
2021-02-27 08:27:40 +01:00
* `range` function now supports negative step and decreasing streams (i.e. to < from ).
2021-02-28 07:38:34 +01:00
* More information is provided to the error variable captured by the `catch` statement in an _object map_ .
2021-03-01 08:39:49 +01:00
* Previously, `private` functions in an `AST` cannot be called with `call_fn` etc. This is inconvenient when trying to call a function inside a script which also serves as a loadable module exporting part (but not all) of the functions. Now, all functions (`private` or not) can be called in an `AST` . The `private` keyword is relegated to preventing a function from being exported.
2021-03-05 06:34:58 +01:00
* `Dynamic::as_unit` just for completeness sake.
2021-03-07 15:33:02 +01:00
* `bytes` method added for strings to get length quickly (if the string is ASCII-only).
2021-03-10 16:01:04 +01:00
* `FileModuleResolver` can now enable/disable caching.
2021-03-11 14:55:55 +01:00
* Recursively walking an `AST` can now be terminated in the middle.
2021-02-27 08:06:57 +01:00
2021-03-02 06:48:41 +01:00
2021-02-18 07:33:12 +01:00
Version 0.19.13
===============
2021-02-27 05:52:20 +01:00
This version introduces functions with `Dynamic` parameters acting as wildcards.
2021-02-18 07:33:12 +01:00
Bug fixes
---------
* Bug in `Position::is_beginning_of_line` is fixed.
2021-02-22 05:38:09 +01:00
Breaking changes
----------------
* For plugin functions, constants passed to methods (i.e. `&mut` parameter) now raise an error unless the functions are marked with `#[rhai_fn(pure)]` .
* Visibility (i.e. `pub` or not) for generated _plugin_ modules now follow the visibility of the underlying module.
2021-02-25 10:52:56 +01:00
* Comparison operators between the sames types or different _numeric_ types now throw errors when they're not defined instead of returning the default. Only comparing between _different_ types will return the default.
2021-02-22 05:38:09 +01:00
* Default stack-overflow and top-level expression nesting limits for release builds are lowered to 64 from 128.
2021-02-26 04:21:23 +01:00
* `Engine::call_fn_dynamic` takes an additional parameter to optionally evaluate the given `AST` before calling the function.
2021-02-22 05:38:09 +01:00
2021-02-19 04:47:26 +01:00
New features
2021-02-18 07:33:12 +01:00
------------
2021-02-23 09:06:36 +01:00
* Functions are now allowed to have `Dynamic` arguments.
2021-02-19 16:13:53 +01:00
* `#[rhai_fn(pure)]` attribute to mark a plugin function with `&mut` parameter as _pure_ so constants can be passed to it. Without it, passing a constant value into the `&mut` parameter will now raise an error.
2021-02-19 04:47:26 +01:00
Enhancements
------------
* Built-in operators between `FLOAT` /[`Decimal`](https://crates.io/crates/rust_decimal) and `INT` are now implemented for more speed under those cases.
2021-02-18 07:33:12 +01:00
* Error position in `eval` statements is now wrapped in an `EvalAltResult::ErrorInFunctionCall` .
* `Position` now implements `Add` and `AddAssign` .
2021-02-18 16:35:22 +01:00
* `Scope` now implements `IntoIterator` .
2021-02-25 06:29:49 +01:00
* Strings now have the `-` /`-=` operators and the `remove` method to delete a sub-string/character.
2021-02-23 04:56:04 +01:00
* Strings now have the `split_rev` method and variations of `split` with maximum number of segments.
2021-02-23 04:57:50 +01:00
* Arrays now have the `split` method.
2021-02-25 06:29:49 +01:00
* Comparisons between `FLOAT` /[`Decimal`](https://crates.io/crates/rust_decimal) and `INT` are now built in.
* Comparisons between string and `char` are now built in.
2021-02-26 04:21:23 +01:00
* `Engine::call_fn_dynamic` can now optionally evaluate the given `AST` before calling the function.
2021-02-18 07:33:12 +01:00
2021-02-03 12:23:50 +01:00
Version 0.19.12
===============
2021-02-17 09:53:35 +01:00
This version is an incremental release with a number of enhancements and bug fixes.
Notice that there are a number of breaking changes, especially with regards to replacing the `~`
exponential operator with `**` , and the addition of the `decimal` feature that turns on
[`Decimal` ](https://crates.io/crates/rust_decimal ) support.
2021-02-09 07:22:55 +01:00
Bug fixes
---------
* Empty statements (i.e. statements with only one `;` ) now parse correctly and no longer hang.
* `continue` , `break` and `return` statements no longer panic inside a `try .. catch` block.
2021-02-13 16:25:22 +01:00
* `round` function for `f64` is now implemented correctly.
2021-02-09 07:22:55 +01:00
2021-02-06 15:16:44 +01:00
Breaking changes
----------------
2021-02-10 05:41:27 +01:00
* In order to be consistent with other scripting languages:
* the power/exponentiation operator is changed from `~` to `**` ; `~` is now a reserved symbol
* the power/exponentiation operator now binds to the right
* trigonometry functions now take radians and return radians instead of degrees
2021-02-06 15:16:44 +01:00
* `Dynamic::into_shared` is no longer available under `no_closure` . It used to panic.
2021-02-10 05:41:27 +01:00
* `Token::is_operator` is renamed to `Token::is_symbol` .
2021-02-13 03:56:09 +01:00
* `AST::clone_functions_only_filtered` , `AST::merge_filtered` , `AST::combine_filtered` and `AST::retain_functions` now take `Fn` instead of `FnMut` as the filter predicate.
2021-02-06 15:16:44 +01:00
2021-02-11 12:20:30 +01:00
New features
------------
* Scientific notation is supported for floating-point number literals.
2021-02-13 13:57:56 +01:00
* A new feature, `decimal` , enables the [`Decimal` ](https://crates.io/crates/rust_decimal ) data type. When both `no_float` and `decimal` features are enabled, floating-point literals parse to `Decimal` .
2021-02-11 12:20:30 +01:00
2021-02-07 08:41:40 +01:00
Enhancements
------------
* Functions resolution cache is used in more cases, making repeated function calls faster.
2021-02-17 05:27:27 +01:00
* Added `atan(x, y)` and `hypot(x, y)` to `BasicMathPackage` .
2021-02-18 16:35:22 +01:00
* Added standard arithmetic operators between `FLOAT` /[`Decimal`](https://crates.io/crates/rust_decimal) and `INT` .
2021-02-07 08:41:40 +01:00
2021-02-06 15:16:44 +01:00
2021-01-15 10:13:24 +01:00
Version 0.19.11
===============
2021-01-20 16:17:28 +01:00
This version streamlines compiling for WASM.
Rust compiler minimum version is raised to 1.49.
2021-01-18 03:30:58 +01:00
Bug fixes
---------
2021-01-23 02:37:27 +01:00
* Parameters passed to plugin module functions were sometimes erroneously consumed. This is now fixed.
2021-01-18 03:30:58 +01:00
* Fixes compilation errors in `metadata` feature build.
2021-01-24 14:21:15 +01:00
* Stacking `!` operators now work properly.
2021-01-29 15:29:36 +01:00
* Off-by-one error in `insert` method for arrays is fixed.
2021-01-31 11:44:50 +01:00
* Invalid property access now throws the appropriate error instead of panics.
2021-01-29 15:29:36 +01:00
Breaking changes
----------------
* Rust compiler requirement raised to 1.49.
* `NativeCallContext::new` taker an additional parameter containing the name of the function called.
* `Engine::set_doc_comments` is renamed `Engine::enable_doc_comments` .
2021-01-18 03:30:58 +01:00
2021-01-20 16:17:28 +01:00
New features
------------
* Two new features, `wasm-bindgen` and `stdweb` , to specify the JS interop layer for WASM builds. `wasm-bindgen` used to be required.
2021-01-18 03:30:58 +01:00
Enhancements
------------
* `ahash` is used to hash function call parameters. This should yield speed improvements.
2021-01-20 16:17:28 +01:00
* `Dynamic` and `ImmutableString` now implement `serde::Serialize` and `serde::Deserialize` .
2021-01-21 14:49:25 +01:00
* `NativeCallContext` has a new field containing the name of the function called, useful when the same Rust function is registered under multiple names in Rhai.
2021-02-09 08:57:38 +01:00
* New functions `PI()` and `E()` to return mathematical constants, and `to_radians` and `to_degrees` to convert between radians and degrees.
2021-01-15 10:13:24 +01:00
2020-12-30 14:12:51 +01:00
Version 0.19.10
===============
2021-01-11 16:09:33 +01:00
Bug fixes
---------
2021-01-14 12:07:03 +01:00
* `no_std` feature now compiles correctly (bug introduced in `0.19.9` ).
2021-01-11 16:09:33 +01:00
* Bug in `FileModuleResolver::clear_cache_for_path` path mapping fixed.
2021-01-14 12:07:03 +01:00
* Some optimizer fringe cases are fixed - related to constants propagation when the evil `eval` is present.
2021-01-11 16:09:33 +01:00
2020-12-30 14:12:51 +01:00
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
------------
2021-01-11 16:09:33 +01:00
* `Engine::compile_into_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.
2021-01-11 16:09:33 +01:00
* A new optional function `resolve_ast` is added to the `ModuleResolver` trait for advanced usage.
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.
2021-12-16 09:10:39 +01: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
----------------
2021-12-16 09:10:39 +01:00
* `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
2021-03-17 02:58:08 +01:00
Breaking changes
----------------
* `Module::contains_fn` and `Module::get_script_fn` no longer take the `public_only` parameter.
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.
2021-12-16 09:10:39 +01:00
* Precedence of the `%` (modulo) operator is lowered to below bit shifts. 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-30 00:19:54 +01:00
The `README` is officially transferred to [The Rhai Book ](https://rhai.rs/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-30 00:19:54 +01:00
* [The Rhai Book ](https://rhai.rs/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>` .
2021-03-02 08:02:28 +01:00
* The `RegisterDynamicFn` trait is merged into the `RegisterResultFn` trait which now always returns `RhaiResult` .
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.