links
links copied to clipboard
Serialise Alien values
trafficstars
Currently, the server refuses to serialise alien values, meaning a program like the following fails to load at runtime
alien javascript "/ffi/impl.js" g : () ~> ();
var ffi = g;
fun mainPage(_) {
page
<#>
<button l:onclick="{ffi()}">ffi()</button>
</#>
}
fun main() {
addStaticRoute("/ffi", "ffi/", [("js", "text/javascript")]);
addRoute("/", mainPage);
servePages()
}
main()
// ffi/impl.js
function g(k) {
console.log("G");
return _applyCont(k, {});
}
There is no need for this restriction. The serialisation of alien values (at least those that come from JavaScript) are trivial to serialise, we simply need to package up the object name.