-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The generators from JS 1.7 are too specific to provide much help with promises, IMO. Adding a yield operator fundamentally alters the semantics of the entire surrounding function, violating the principle of locality. Consequently you need special mechanisms (like Neil's library) to even call an async function, and you can't "return" values either (with the return operator). Solving these problems was the point behind the shallow continuation proposal that we worked on. Does the generator strawman build on that work, or does it still fail to preserve locality?
My understanding of Kyle's proposal was that he did not want to introduce real continuations, but this was more of a syntax for a specialized callback chain, reducing the verbosity of anon functions, callback registration. I'd prefer more of a generalized solution for reducing the size of anon functions (which has been discussed to great lengths here in the lambda threads). However, my belief on async is that the verbosity is only part of the pain, working with async within various control flows (loops, branches, etc) is more of a burden, hence the need for continuations (shallow/single frame, of course). Kris On 12/9/2010 8:55 AM, David Herman wrote: > I pretty much abandoned that line of investigation with the > conclusion that generators: > > http://wiki.ecmascript.org/doku.php?id=strawman: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: > > http://github.com/dherman/jstask > > Somebody reminded me that Neil Mix had written a very similar > library several years ago, called Thread.js: > > http://www.neilmix.com/2007/02/07/threading-in-javascript-17/ > > and there's another library called Er.js that built off of that to > create some Erlang-like abstractions: > > http://www.beatniksoftware.com/erjs/ > > Dave > > 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") >> https://mail.mozilla.org/pipermail/es-discuss/2010-March/010865.html >> >> 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: >> https://mail.mozilla.org/pipermail/es-discuss/2010-April/010894.html >> >> Cheers, >> Tom >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org <mailto:es-discuss@mozilla.org> >> https://mail.mozilla.org/listinfo/es-discuss > > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss - -- Kris Zyp SitePen (503) 806-1841 http://sitepen.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0BA5kACgkQ9VpNnHc4zAy7nwCeJxL8Or+BUkYzfAi46EKEQG+O nGEAn0nCErWiI5mbunUwD860Czeof1bt =fHWD -----END PGP SIGNATURE-----
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss