TyOverby / ares

A Lisp made for easy integration with Rust.
9 stars 1 forks source link

Redo rust-based "foreign" functions #9

Closed TyOverby closed 9 years ago

TyOverby commented 9 years ago

This is a pretty big change to how FFI functions work. Instead of having two different kinds of foreign functions FreeFunction and UnevalFunction, this work unifies them into one.

This "one" function type has the same signature as the previous UnevalFunction. However for utility, it takes a slice of values rather than an iterator. (it turns out that the perf benefit from using an iterator was non existent).

However, functions that used to be "free functions" are still usable by passing them through the free_fn function. This works by boxing up a closure that evaluates the arguments and gives them to the passed-in function.

Functions that used to be called UnevalFunctions are now called ast_fn in order to make it obvious that you are operating on an AST, not actual values.

In the future, I have plans for more function types.

TODO: most of the standard library code was written using iterators, and it looks really bad now... Tests pass by turning the slices into iterators (like they were before), but the code looks really ugly.

bwo commented 9 years ago

nice!