natively negotiating sync vs. async...without callbacks
dherman at mozilla.com
Thu Dec 9 07:55:55 PST 2010
I pretty much abandoned that line of investigation with the conclusion that generators:
are a good (and well-tested, in Python and SpiderMonkey) design for single-frame continuations. They hang together well; in particular, they don't have the issues with `finally' that some of the alternatives I talked about do. Moreover, the continuation-capture mechanisms based on call/cc or shift/reset require additional power in the VM to essentially tail-call their argument expression. When I tried prototyping this in SpiderMonkey, I found this to be one of the biggest challenges -- and that was just in the straight-up interpreter, not in the tracing JIT or method JIT.
Generators work well for lightweight concurrency. As a proof of concept, I put together a little library of "tasks" based on generators:
Somebody reminded me that Neil Mix had written a very similar library several years ago, called Thread.js:
and there's another library called Er.js that built off of that to create some Erlang-like abstractions:
On Dec 8, 2010, at 11:36 PM, Tom Van Cutsem wrote:
> The spirit of the proposal is that this special type of statement be a linear sequence of function executions (as opposed to nested function-reference callbacks delegating execution to other code).
> The special behavior is that in between each part/expression of the statement, evaluation of the statement itself (NOT the rest of the program) may be "suspended" until the previous part/expression is fulfilled. This would conceptually be like a yield/continuation localized to ONLY the statement in question, not affecting the linear execution of the rest of the program.
> This reminds me of a proposal by Kris Zyp a couple of months ago ("single frame continuations")
> I don't think that discussion lead to a clear outcome, but it's definitely related, both in terms of goals as well as in mechanism.
> I also recall it prompted Dave Herman to sketch the design space of (single-frame) continuations for JS:
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss