Skip to content

Releases: rhaiscript/rhai

v.0.19.5

10 Nov 03:38
9bf8219
Compare
Choose a tag to compare

This version fixes a bug that prevents compilation with the internals feature.
It also speeds up importing modules.

Version 0.19.5 released to crates.io.

Bug fixes

  • Fixes compilation error when using the internals feature. Bug introduced in 0.19.4.
  • Importing script files recursively no longer panics.

Breaking changes

  • Modules imported at global level can now be accessed in functions.
  • ModuleResolver::resolve now returns Shared<Module> for better resources sharing when loading modules.
  • ParseErrorType::DuplicatedExport is removed as multiple export's are now allowed.

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.
  • 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;
  • Variables can now be export-ed multiple times under different names.
  • index_of, == and != are defined for arrays.
  • == and != are defined for object maps.

v.0.19.4

04 Nov 09:29
b464207
Compare
Choose a tag to compare

Note: Timed this to USA presidential election day just for kicks...

This version basically cleans up the code structure in preparation for a potential 1.0 release in the future.
Most scripts should see a material speed increase.

This version also adds a low-level API for more flexibility when defining custom syntax.

Version 0.19.4 released to crates.io.

Bug fixes

  • Fixes Send + Sync for EvalAltResult under the sync feature. Bug introduced with 0.19.3.

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.

Changes to Error Handling

  • EvalAltResult::ErrorAssignmentToUnknownLHS is moved to ParseError::AssignmentToInvalidLHS. ParseError::AssignmentToCopy is removed.
  • EvalAltResult::ErrorDataTooLarge is simplified.
  • Engine::on_progress closure signature now returns Option<Dynamic> with the termination value passed on to EvalAltResult::ErrorTerminated.
  • ParseErrorType::BadInput now wraps a LexError instead of a text string.

New features

  • f32_float feature to set FLOAT to f32.
  • Low-level API for custom syntax allowing more flexibility in designing the syntax.
  • Module::fill_with to poly-fill a module with another.
  • Scripts terminated via Engine::on_progress can now pass on a value as a termination token.

Enhancements

  • 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-Boxed as much as possible.
  • Scope is optimized for cache friendliness.

v.0.19.3

22 Oct 04:49
caa95d8
Compare
Choose a tag to compare

This version adds the try ... catch statement to catch errors and exceptions. It also streamlines some of the advanced API's.

Version 0.19.3 released to crates.io.

Breaking changes

  • EvalAltResult::ErrorReadingScriptFile is removed in favor of the new EvalAltResult::ErrorSystem.
  • EvalAltResult::ErrorLoopBreak is renamed to EvalAltResult::LoopBreak.
  • Engine::register_raw_fn and FnPtr::call_dynamic function signatures have changed.
  • Callback signatures to Engine::on_var and Engine::register_custom_syntax have changed.
  • 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.

New features

  • The plugins system is enhanced to support functions taking a NativeCallContext as the first parameter.
  • throw statement can now throw any value instead of just text strings.
  • New try ... catch statement to catch exceptions.

Enhancements

  • Calling eval or Fn in method-call style, which is an error, is now caught during parsing.
  • func!() call style is valid even under no_closure feature.

v.0.19.2

16 Oct 13:36
bd90f3c
Compare
Choose a tag to compare

This version adds a variable resolver with the ability to short-circuit variable access,
plus a whole bunch of array methods.

Version 0.19.2 released to crates.io.

Breaking changes

  • AST::iter_functions now returns an iterator instead of taking a closure.
  • Module::get_script_function_by_signature renamed to Module::get_script_fn and returns &<Shared<ScriptFnDef>>.
  • Module::num_fn, Module::num_var and Module::num_iter are removed and merged into Module::count.
  • 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.
  • The following EvalAltResult variants are removed and merged into EvalAltResult::ErrorMismatchDataType: ErrorCharMismatch, ErrorNumericIndexExpr, ErrorStringIndexExpr, ErrorImportExpr, ErrorLogicGuard, ErrorBooleanArgMismatch
  • Scope::iter_raw returns an iterator with an additional field indicating whether the variable is constant or not.
  • rhai::ser and rhai::de namespaces are merged into rhai::serde.
  • New reserved symbols: ++, --, .., ....
  • Callback signature for custom syntax implementation function is changed to allow for more flexibility.
  • Default call stack depth for debug builds is reduced to 12 (from 16).
  • Precedence for ~ is raised, while in is moved below logic comparison operators.

New features

  • New Engine::on_var to register a variable resolver.
  • const statements can now take any expression (or none at all) instead of only constant values.
  • OptimizationLevel::Simple now eagerly evaluates built-in binary operators of primary types (if not overloaded).
  • is_def_var() to detect if variable is defined, and is_def_fn() to detect if script function is defined.
  • Dynamic::from(&str) now constructs a Dynamic with a copy of the string as value.
  • AST::combine and AST::combine_filtered allows combining two AST's without creating a new one.
  • map, filter, reduce, reduce_rev, some, all, extract, splice, chop and sort functions for arrays.
  • New Module::set_iterable and Module::set_iterator to define type iterators more easily. Engine::register_iterator is changed to use the simpler version.

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.

v.0.19.0

01 Oct 02:52
fca908e
Compare
Choose a tag to compare

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.

Version 0.19.0 released to crates.io.

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.
  • Module API's now properly handle &str and String parameters.
  • Indexers are available under no_object.
  • Registered operator-assignment functions (e.g. +=) now work correctly.

Breaking changes

  • Engine::register_set_result and Engine::register_indexer_set_result now take a function that returns Result<(), Box<EvalAltResult>>.
  • Engine::register_indexer_XXX and Module::set_indexer_XXX panic when the type is Array, Map or String.
  • 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.
  • 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.
  • New EvalAltResult::ErrorInModule variant capturing errors when loading a module from a script file.

New features

  • Plugins support via procedural macros.
  • Scripted functions are allowed in packages.
  • parse_int and parse_float functions for parsing numbers; split function for splitting strings.
  • AST::iter_functions and Module::iter_script_fn_info to iterate functions.
  • Functions iteration functions for AST and Module now take FnMut instead of Fn.
  • New FileModuleResolver that encapsulates the entire AST of the module script, allowing function cross-calling. The old version is renamed MergingFileModuleResolver.
  • + and - operators for timestamps to increment/decrement by seconds.

v.0.18.3

29 Aug 08:00
3892ffe
Compare
Choose a tag to compare

This is a bug-fix release. Version 0.18.3 now released to crates.io.

Bug fixes

  • Engine::compile_expression, Engine::eval_expression etc. no longer parse anonymous functions and closures.
  • Imported modules now work inside closures.
  • Closures that capture now work under no_object.

v.0.18.2

20 Aug 14:24
87685f6
Compare
Choose a tag to compare

Version 0.18.2 released to crates.io.

Bug fixes

  • Fixes bug that prevents calling functions in closures.
  • Fixes bug that erroneously consumes the first argument to a module-qualified function call.

New features

  • Adds Engine::register_get_result, Engine::register_set_result, Engine::register_indexer_get_result, Engine::register_indexer_set_result API.
  • Adds Module::combine to combine two modules.
  • Engine::parse_json now also accepts a JSON object starting with #{.

v.0.18.1

05 Aug 14:56
75fd9f9
Compare
Choose a tag to compare

Version 0.18.1 released to crates.io

This version adds:

  • Anonymous functions (in Rust closure syntax). Simplifies creation of single-use ad-hoc functions.
  • Currying of function pointers.
  • 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.
  • Binding the this pointer in a function pointer call.
  • Capturing call scope via func!(...) syntax.

New features

  • call can now be called function-call style for function pointers - this is to handle builds with no_object.
  • Reserve language keywords, such as print, eval, call, this etc.
  • x.call(f, ...) allows binding x to this for the function referenced by the function pointer f.
  • Anonymous functions are supported in the syntax of a Rust closure, e.g. |x, y, z| x + y - z.
  • Custom syntax now works even without the internals feature.
  • Currying of function pointers is supported via the new curry keyword.
  • Automatic currying of anonymous functions to capture shared variables from the external scope.
  • Capturing of the calling scope for function call via the func!(...) syntax.
  • Module::set_indexer_get_set_fn is added as a shorthand of both Module::set_indexer_get_fn and Module::set_indexer_set_fn.
  • New unicode-xid-ident feature to allow Unicode Standard Annex #31 for identifiers.
  • Scope::iter_raw returns an iterator with a reference to the underlying Dynamic value (which may be shared).

Breaking changes

  • Language keywords are now reserved (even when disabled) and they can no longer be used as variable names.
  • Function signature for defining custom syntax is simplified.
  • Engine::register_raw_fn_XXX API shortcuts are removed.
  • 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.
  • The iterator returned by Scope::iter now contains a clone of the Dynamic value (unshared).
  • Engine::load_package takes any type that is Into<PackageLibrary>.
  • Error in Engine::register_custom_syntax is no longer Box-ed.

Housekeeping

  • Most compilation warnings are eliminated via feature gates.

v.0.17.0

13 Jul 11:46
15292f4
Compare
Choose a tag to compare

Version 0.17.0 released to crates.io

This version adds:

  • serde support for working with Dynamic values (particularly object maps).
  • Low-level API to register functions.
  • Surgically disable keywords and/or operators in the language.
  • Define custom operators.
  • Extend the language via custom syntax.

Bug fixes

  • Fixed method calls in the middle of a dot chain.

Breaking changes

  • EvalAltResult::ErrorMismatchOutputType has an extra argument containing the name of the requested type.
  • Engine::call_fn_dynamic take an extra argument, allowing a Dynamic value to be bound to the this pointer.
  • Precedence of the % (modulo) operator is lowered to below << ad >>. This is to handle the case of x << 3 % 10.

New features

  • New serde feature to allow serializating/deserializating to/from Dynamic values using serde.
    This is particularly useful when converting a Rust struct to a Dynamic object map and back.
  • Engine::disable_symbol to surgically disable keywords and/or operators.
  • Engine::register_custom_operator to define a custom operator.
  • Engine::register_custom_syntax to define a custom syntax.
  • New low-level API Engine::register_raw_fn and Engine::register_raw_fn_XXX.
  • New low-level API Module::set_raw_fn mirroring Engine::register_raw_fn.
  • AST::clone_functions_only, AST::clone_functions_only_filtered and AST::clone_statements_only to clone only part of an AST.
  • The boolean ^ (XOR) operator is added.
  • FnPtr is exposed as the function pointer type.
  • rhai::module_resolvers::ModuleResolversCollection added to try a list of module resolvers.
  • It is now possible to mutate the first argument of a module-qualified function call when the argument is a simple variable (but not a module constant).
  • Many configuration/setting API's now returns &mut Self so that the calls can be chained.
  • String parameters in functions are supported (but inefficiently).

v.0.16.1

01 Jul 14:26
3b16fae
Compare
Choose a tag to compare

The major new feature in this version is OOP - well, poor man's OOP, that is.

Version 0.16.1 released to crates.io

The README is officially transferred to The Rhai Book.

An online Playground is available.

Breaking changes

  • The trait function ModuleResolver::resolve no longer takes a Scope as argument.
  • Functions defined in script now differentiates between using method-call style and normal function-call style.
    The method-call style will bind the object to the this parameter instead of consuming the first parameter.
  • Imported modules are no longer stored in the Scope. Scope::push_module is removed.
    Therefore, cannot rely on module imports to persist across invocations using a Scope.
  • AST::retain_functions is used for another purpose. The old AST::retain_functions is renamed to AST::clear_statements.

New features

  • Support for function pointers via Fn(name) and Fn.call(...) syntax - a poor man's first-class function.
  • Support for calling script-defined functions in method-call style with this binding to the object.
  • Special support in object maps for OOP.
  • Expanded the AST API for fine-tuned manipulation of functions.

Enhancements

  • The Rhai Book is online. Most content in the original README was transferred to the Book.
  • New feature internals to expose internal data structures (e.g. the AST nodes).