Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reentrant Engine, Rust anonymous functions, in expression, timestamps, bug fixes #128

Merged
merged 21 commits into from
Apr 13, 2020

Conversation

schungx
Copy link
Collaborator

@schungx schungx commented Apr 6, 2020

This PR does the following:

  • call_fn now has only one version and handles tuples of one/zero
  • optimize_ast can now control the optimization level
  • add in expressions
  • add timestamp which is basically std::time::Instant to do rudimentary timing
  • deprecates the no_stdlib feature - use Engine::new_raw to create raw Engine
  • fix the max call-depth limit so it properly throws a stack overflow error instead of panic-ing
  • fix bug in escaping single/double quotes in character/string literals
  • Engine is now re-entrant
  • support for creating anonymous functions in Rust which transparently calls into an Engine via call_fn
  • Error enums are not omitted when certain features are turned on - this is to avoid the application needing to constantly uncomment/comment out match variants when using features.
  • supports parsing JSON into an object map
  • some more utility functions for arrays and object maps

@schungx schungx changed the title In expression Reentrant Engine, In expression Apr 7, 2020
@schungx schungx mentioned this pull request Apr 7, 2020
Closed
@schungx schungx changed the title Reentrant Engine, In expression Reentrant Engine, in expression, bug fixes Apr 7, 2020
@schungx schungx linked an issue Apr 8, 2020 that may be closed by this pull request
@schungx schungx changed the title Reentrant Engine, in expression, bug fixes Reentrant Engine, Rust anonymous functions, in expression, bug fixes Apr 8, 2020
@jhwgh1968
Copy link
Contributor

Small question: is there a better name than "anonymous functions"?

I always think of the lambda-like functions that rust has:

let x = |f| { f == 0 };
assert!(x(0));

I interpret this as more like "exported functions", where a named function in Rhai gets a function pointer in Rust.

(It might be useful for Rhai to support the syntax above, but that's a separate topic.)

@schungx
Copy link
Collaborator Author

schungx commented Apr 11, 2020

I always think of the lambda-like functions that rust has:

Well, I thought about the name also. However, lambda seems to imply that it somehow captures its environment as a closure, which this is not. Rust's closures (basically lambda's) have a specific meaning.

This is more like a curryed function...

And this is what Rust's documentation says about anonymous functions:

https://doc.rust-lang.org/stable/book/ch13-01-closures.html

@schungx schungx changed the title Reentrant Engine, Rust anonymous functions, in expression, bug fixes Reentrant Engine, Rust anonymous functions, in expression, timestamps, bug fixes Apr 11, 2020
@schungx schungx merged commit 2330dcb into rhaiscript:master Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants