yield and Promises

Mark S. Miller erights at google.com
Fri Oct 21 10:46:05 PDT 2011


On Fri, Oct 21, 2011 at 10:20 AM, John J Barton <johnjbarton at johnjbarton.com
> wrote:

>
>
> On Fri, Oct 21, 2011 at 9:41 AM, Brendan Eich <brendan at mozilla.com> wrote:
>
>> On Oct 21, 2011, at 9:34 AM, John J Barton wrote:
>>
>> Can anyone summarize how these proposals relate to Kris Kowal / Kris Zyp /
>> Mark Miller Q library:
>> https://github.com/kriskowal/q
>>
>>
>>
In the credit where due dept., the original Q library is Tyler Close's
ref_send library. Other related and prior work is linked to at
http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#see





> Did you see
>> https://github.com/kriskowal/q/tree/master/examples/async-generators yet?
>>
>
> Thanks, I think that page clarifies my issue with generators: they solve a
> problem I don't have.
>

In that case, you might be equally uninterested ;) in

http://wiki.ecmascript.org/doku.php?id=strawman:async_functions#reference_implementation

which shows how to do the same thing with generators as proposed for
ES-next.



> See below.
>
>
>>
>>
>> In my experience, reasoning about the code was much easier with Q than
>> without Q.  (Not something I found in trying generators).
>>
>>
>> In order to say something that isn't subjective yet content-free other
>> than negative, what was hard to reason about, and why? Can you give three
>> examples?
>>
>
> I only mentioned generators since Zyp's proposal uses yield. Now I'm
> regretting it because I really wanted to highlight Q.
>
> My comment is entirely subjective and intended to be positive about Q.
>

Thanks! I am positive about Q as well. And yes, I like Kris Kowal's
implementation.



>
> The examples on the async-generators page cites above are clearer than the
> ones on the MDC generators page because they focus on "next()". The strong
> case for generators is support for generic, encapsulated iteration. Examples
> illustrating this power would go a long way to build the case for them IMO.
> Examples of quirky iteration do not.
>
> Now back to Zyp's key point: using async functionality for iteration,
> powerful or not, does not address the key use-case for async.
>
> In particular, Q simplifies joining parallel async operations (XHR,
> postMessages, 'load', 'progress' events). Of course it may well be that
> generators provide an elegant solution to this important problem, but I've
> not seen such examples.
>

Have you seen
http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#q.race and
http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#q.all ? If these
don't address the joining you have in mind, could you post some examples?
Thanks.



>
>
> jjb
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111021/a34c1e71/attachment.html>


More information about the es-discuss mailing list