Proposal: use "One More Point" to handle async functions

Caitlin Potter caitpotter88 at gmail.com
Tue Sep 27 17:14:46 UTC 2016


> On Sep 27, 2016, at 6:24 PM, Li Xiaolong <898310778 at outlook.com> wrote:
> 
> > That’s not necessarily true — `await` in modules may be very different from this.
> 
> I don’t know what await in modules look like.

It’s still being discussed. I think there are some strong arguments for top-level “await”, which is the only case where you’re (currently) forced to be in a synchronous mode.

> 
> > You might be confused about something — if an awaited Promise is rejected, the async function can be resumed from a catch block to handle the rejection.
> 
> I know await can be catched. But the redundant reject state in promise makes it more confusing.

What “redundant reject state”? What is redundant? And more importantly, how is it confusing? It maps to the same syntax of typical synchronous code, which is pretty clear about the error state vs non-error state.

> 
> > I’m not sure everyone shares this view — many people laud other languages where coroutines (for example) are indistinguishable from regular subroutines.
> 
> Well, when you are debugging and can’t find where the code waits, you’ll miss the OMP.

That sounds like a puzzle for the DevTools team to solve :) There’s no reason the inspector couldn’t see this.

> 
> > How?
> I thought it again. Can I write: ‘await obj2.doSomeOtherThing(await obj1.doSomeThing())’? If I can, then the await is not more complex than OMP when dealing with deep async, just a little longer.

Yes, AwaitExpressions are just a form of UnaryExpression, and can be used anywhere a UnaryExpression is used (including as an operand to a function which is being `await`-ed.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160927/94e398cf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160927/94e398cf/attachment.sig>


More information about the es-discuss mailing list