4 ms·
> Webassembly really could enable seamless cross-language integration in the future. > Writing a project in Rust, but really want to use that popular face dete
by ori_b 7y ago
> Webassembly really could enable seamless cross-language integration in the future.
> Writing a project in Rust, but really want to use that popular face detector written in Python?
So, how exactly do you magically enforce affine type semantics in the data you pass to wasm-python, and transparently forward calls to the bound __call__ method of python objects?
The calls are easy, even today. Semantics are hard.
- cesarb 7y ago> So, how exactly do you magically enforce affine type semantics in the data you pass to wasm-python In Rust, calling foreign functions is considered unsafe, precisely for that reason: once you leave the boundaries of a single language, the compiler can no longer enforce these invariants for you.
- ori_b 7y agoSo, the solution is to make more or less every foreign call unsafe. That's pretty close to the state of the art without wasm. I'm not sure how satisfactory that is, especially when it is fairly idiomatic for many calls in garbage collected languages to both keep and return a reference (eg, builder pattern), which may lead to rust calling a destructor where the other language doesn't expect it.
- the_duke 7y agoIf I understand the proposal correctly, it should actually be possible to auto-generate safe glue code. These interface types can describe, eg, how to map a Python String or list to a generic representation (pointer + length), and Rust can then take this generic form and map it into a valid Rust string safely - with the intermediate guarantees verified by the WASM runtime.