links icon indicating copy to clipboard operation
links copied to clipboard

Serialise Alien values

Open dhil opened this issue 4 years ago • 0 comments
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.

dhil avatar Jul 14 '21 17:07 dhil