These are chat archives for ChaiScript/ChaiScript

May 2015
Jason Turner
May 17 2015 00:00
futures, yes. you can do: var f = async(fun(){ return 1; }); f.get()
continuations, no
Luka Rahne
May 17 2015 09:36

General Idea I have is, is that that continuation wrapper returns (from script to c++) top of stack and ast, wrapped into functor. Continuation/promise can be evaluated at any time where stack and local data is released by functor caller by disposing this object.

Maybe I'll take look later into this more. Do you have any Idea where this might fail?

Jason Turner
May 17 2015 14:21

Give it a try. I think where I started giving up is that you have to not just return to the AST node that the continuation was started, but you also have to return the call stack in place


def myfun() {
  while (something) {
    yield somevalue; // if you want to return to here, you need to know
                                       // that you are inside of the while loop, inside of the function
                                       // so that when `something` becomes false you drop out of the while
                                       // and continue properly with the rest of the function
  return; // all done, `something` is now false
Unless I'm missing something. I'm not terribly familiar with co-routines and continuations and such.