Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread David Herman
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

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread David Herman
PS To be concrete, here's an example code snippet using my jstask library that chains several event-generated actions together in a natural way (i.e., in direct style, i.e. not in CPS): var task = new Task(function() { var request = new HttpRequest(); try { var

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread Shriram Krishnamurthi
It might surprise some who know me to hear this, but I agree with Dave on this. There's a huge gap between the single-frame mechanism and going the whole hog. Going all out does buy you some expressive power, but at the cost of complicating everything. If the simple mechanism gives you most of

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread Kris Zyp
-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

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread Getify Solutions
var task = new Task(function() { var request = new HttpRequest(); try { var foo = yield request.send(this, foo.json); var bar = yield request.send(this, bar.json); var baz = yield request.send(this, baz.json); } catch

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread Getify Solutions
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

Re: natively negotiating sync vs. async...without callbacks

2010-12-09 Thread Brendan Eich
On Dec 9, 2010, at 3:27 PM, David Herman wrote: I'm not trying to open the can-o'-worms around block level changes. The above code suggests that a 'yield' suspension of execution is local to the nearest container { } block, in this case the try { } block. No, that's not the case. That