Funct
I created funct for use in my editor Jim. I originally start with rhai but found the lack of being able to pause execution too limiting. I use funct for all my widgets and want to make sure an infinite loop doesn't cause my frames to drop. This feature right now is still definitely not fully tested, but it was crucial for my future plans so it felt worth making this.
This software is Pre-Alpha. I will make breaking changes and it is very untested. (This library has been vibe coded.)
Docs: Language Guide · Standard Library · Spec
A taste of the language
type Shape = Circle | Square
= match s
let shapes =
let total = shapes |> map |> sum
let hits = atom
swap!
match parse_pair
Embedding in Rust
use ;
let mut vm = new;
// expose Rust functions — arguments and return values convert automatically
vm.register1;
vm.register2;
// or expose a whole Rust type, with constructors, fields, and methods
vm.
.ctor2
.field
.method1;
// or bundle functions into a module the script can import
vm.register3;
let lerp = vm.native_fn.unwrap;
vm.register_module;
vm.eval?;
// and call back into the script from Rust, with a typed return
let result: i64 = vm.call_typed?;
Built for live editing: pause, snapshot, resume
use ;
use Duration;
let mut vm = new;
vm.eval?;
// run with a deterministic instruction budget instead of to completion
let mut st = vm.start?;
match vm.run
let mut vm = new;
let mut st = vm.restore_state?;
vm.run;
License
MIT — see LICENSE.