Foreign function interface
Example code using this new FFI for a basic todo app: https://gist.github.com/davexunit/e6ea8da921bcce7ed9c77035139a9527
The new stuff:
- New
%wasm-importform - New
define-foreignmacro to make it easy to define imports - New
external?andexternal-null?predicates - New
procedure->externalto wrap Scheme procedures for use in JS DOM event listeners, etc. - Reflection interface now supports user import specification to provide the host functions for the FFI
Issues/questions:
- Potential for name collisions when using
%wasm-importto declare an import. Shouldn't be an issue fordefine-foreigndue to the use ofgensym. (which, btw, I addedgensymto the primitives module... is that OK?) -
%wasm-importcompiles a 0 valued continuation. Should it do something different? - Names. I keep swapping between "foreign" and "host" in the names of things. Needs some consistency.
- There's some stuff I don't understand about the expansion-time environment. Could we get more useful stuff into it and clean up the
define-foreignmacro a bit?
TODO:
Needs some tests.
Fixes #70 (closed)
Edited by David Thompson