murarth / ketos

Lisp dialect scripting and extension language for Rust programs
Apache License 2.0
751 stars 45 forks source link

Added convenience macro for defining foreign functions from closures #53

Closed ysimonson closed 5 years ago

ysimonson commented 5 years ago

Maybe useful enough to bring in? I've been using this macro to define foreign functions from closures.

A couple of examples:

ketos_closure!(scope, "pid", || -> u32 {
    Ok(process::id())
});

ketos_closure!(scope, "setenv", |key: &str, value: &str| -> () {
    env::set_var(key, value);
    Ok(())
});
murarth commented 5 years ago

Looks great. Thanks!