The problem is not limited to linear block of statements and parallel 
branches:

What about async calls inside if/else branches, inside loops, inside 
try/catch or try/finally? 
What about async calls in call chains (f1().f2().f3()), in functional 
composition (f1(f2(f3()))? 
What about async calls in operands (f1() + f2(), f1() && f2()), in object 
or array initializers (arr = [f1(), f2(), f3()],
etc.

>From my experience with a lot of code sitting on top async APIs (mongodb, 
web services, streams, etc.), there are lots of cases where async calls are 
naturally nested in such constructs. For an example, take a look at the 
streamline tutorial around line 100: return coln.find(..., _).toArray(_).map
(...).join(...)

Libraries, whether they are callback based or promise based, don't help 
with these situations: you have no choice but introduce extra variables and 
split the expressions artificially on async boundaries. To me this makes 
JavaScript look like a broken language. I want the ability to embed async 
calls anywhere, chain them, etc. This is why I attacked the problem with a 
compiler tool rather than a library.

A bench with a non trivial real world scenario would be really helpful. 
Otherwise discussions tend to be too focused on "blocks of async 
statements" and they miss important aspects of coding around async APIs.


On Sunday, March 31, 2013 8:28:33 PM UTC+2, Adam Crabtree wrote:
>
> With all the back and forth and prostelatizing on why Promises are better, 
> etc... I'd like to put together an example of non-trivial implementations 
> of each to help cut through some of the noise and make it easier for people 
> to decide which they prefer.
>
> Ideally, the implementation would be something of sufficient complexity to 
> show off the strengths and weaknesses of each, but easily contained and 
> comprehended in a single file.
>
> Suggestions?
>
> Cheers,
> Adam Crabtree
>
> -- 
> Better a little with righteousness 
>        than much gain with injustice.
> Proverbs 16:8 
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to