rhaiscript / rhai

Rhai - An embedded scripting language for Rust.
https://crates.io/crates/rhai
Apache License 2.0
3.73k stars 175 forks source link

Tracking issue for new features #100

Closed schungx closed 3 years ago

schungx commented 4 years ago

pre 1.0

1.0

closed

luciusmagn commented 4 years ago

Oh wow, there's been a lot of neat development that eluded my sight. That's awesome :D I'll see if I can help with some of these in the future!

schungx commented 4 years ago

Kudos to the team that laid all the superb groundwork beforehand!

schungx commented 4 years ago

I'm probably spending way more time on this than I really should... but...

it seems like the language is at a reasonably stable state with most of the low hanging fruits already picked. To speed up Rhai further will really require some hefty architectural changes, time for which may be productively spent on implementing other useful features instead.

So... what feature do you fancy to be added to Rhai next?

I would probably pick one of the following:

vi commented 4 years ago

Is version 1.0 (or next intermediate semver-incompatible version) a good chance to fix Cargo features to be positive instead of negative?

schungx commented 4 years ago

I am still divided on this - on the one hand, it may break a lot of existing code. On the other hand, it conforms to "standard".

I think I'll let the community ponder it more before deciding to change it for 1.0...

Eliah-Lakhin commented 4 years ago

@schungx Personally I would vote for this one:

first-class functions and closures

Even having first-class functions without closures would be very good. This is something I need to make structural data constructions more concise in my project that is using rhai extensively.

I would suggest a syntax in a form conformed with Rust, so something like |x, y, z| (x + y) / z and/or |x, y, z| {let sum = x + y; sum / z}.

Will be happy to help with this implementation if you need more hands. LMK. Thanks!

schungx commented 4 years ago

Actually I've already put in place all the mechanism needed to parse the closure syntax.

The current idea is |x, y, z| expr will create an anonymous function based on the hash of the function body. Say it is fn $abcdefg1234567$(x, y, z). Then it will replace the closure with Fn("$abcdefg1234567$").

Then other than not being able to capture the running environment, this will look almost like standard OOP.

schungx commented 4 years ago

Anonymous functions (not closures) support already in, together with the ability to curry a function.

schungx commented 4 years ago

Full closures with capturing merged in.

This is thanks to the work of @Eliah-Lakhin

Eliah-Lakhin commented 4 years ago

And I want to say thank you to @schungx for his great work in development and maintenance of Rhai! Without his help in stabilizing of my prototype and implementing of other related features it wouldn't be possible to deliver this feature that fast.

Rhai in my opinion is the most promising and well maintained embedded scripting project in Rust ecosystem.

schungx commented 4 years ago

Plugins system (powered by procedural macros) merged in.

Thanks to @jhwgh1968

Documentation: https://schungx.github.io/rhai/vnext/plugins/index.html

schungx commented 3 years ago

A minor new feature lands: try ... catch statements.

https://schungx.github.io/rhai/vnext/language/try-catch.html

A try block catches most catchable errors, other than non-catchable ones... well...

The particular implementation technique of treating return values and loop breaks from the very beginning of this repo translates well to implementing this, which took very little time and very little code for perhaps a high impact new language feature.

schungx commented 3 years ago

Deprecating this list in favor of new feature requests as new issues.