Arc Forumnew | comments | leaders | submitlogin
5 points by suzuki 1480 days ago | link | parent

It is my pleasure.

As I referred in, the implementation of this arc's continuations is based on If you are planning to port this arc to JavaScript, I suggest reading which implements the continuations in the same way in TypeScript.

And in the latter, the display function

  c('display', 1, x => {
      write(stringify(fst(x), false));
      return new Promise(resolve => {
          runOnNextLoop(() => resolve(None));
is applied asynchronously, in a sense, as follows:

  case ContOp.ApplyFun: // exp2 is a function.
      [exp, env] = applyFunction(exp2, args, k, env);
      if (exp instanceof Promise)
          exp = await exp;
This means the web page is still interactive during the evaluation effectively. Here is an example: Click the "Load" button twice and you will see two "yin-yang puzzle" threads run on the page. Click the "Stop at Writing" button twice to stop them.