Closed ubolonton closed 5 years ago
How about an Env::call
like that:
fn call(&self, name: &str, args: &[impl IntoLisp]) -> Result<Value<'_>>
Maybe with a trait similar to IntoLisp
that doesn't take the ownership of the values ?
That would only work when all arguments have the same type.
// Would work.
env.call("list", &[1, 2])
// Wouldn't work.
env.call("list", &[1, "2"])
Besides, it wouldn't solve the heap allocation issue, since slices are dynamic sized.
Maybe we could use tuples instead of slices.
env.call("list", (1, "2"))
That would probably be a new trait with implementations for tuples, arrays and slices.
call(&self, name: &str, args: impl IntoLispArgs) -> Result<Value>
Currently Lisp functions are called using
Env::call
. This has 2 drawbacks:Value
. This requires a lot of.into_lisp(env)?
and.into_rust()
boilerplate.emacs_value
arguments, while most of the time the number of arguments is statically known.These can be solved by a macro. A basic version already exists as an internal macro:
call_lisp!
.