async/await -> await/async: a simpler, less error-prone async syntax

Alexander Jones alex at weej.com
Mon Feb 12 21:55:19 UTC 2018


FTR, TypeScript and Flow (I assume) know when the static type of a function
call (or any other expression that evaluates to a Promise) is a Promise,
and if you try to use it as if it wasn't, it will almost surely be a type
error.

On 12 February 2018 at 10:27, Алексей <agat00 at gmail.com> wrote:

> I think there is something we could have right now to solve the problem of
> missing `await` without changes to the ES - it should be collored
> differently in IDE or texteditor you are using. Not like an error - because
> it's actually not. But to be obvious that "here" and "here" you have an
> `async` function calls and values are promises
>
> 2017-12-08 6:27 GMT+02:00 Naveen Chawla <naveen.chwl at gmail.com>:
>
>> Um, no the increased rate of productivity is in converting
>>
>> ```js
>> getUserInfoAsync()
>>     .then(
>>         userInfo=>{
>>              //Do stuff with userInfo
>>         }
>>     )
>> ```
>>
>> into
>>
>> ```js
>> const userInfo = await getUserInfoAsync();
>> //Do stuff with userInfo
>> ```
>>
>> ...allowing complex async data flows to be expressed much more simply,
>> hence more quickly, more manageably and with less chance of bugs/mistakes.
>> The `autoasync` `background` concept makes this even more so, hence why I
>> would use it throughout instead of `await` `async` if introduced
>>
>>
>> On Thu, 7 Dec 2017 at 21:41 Florian Bösch <pyalot at gmail.com> wrote:
>>
>>> I fail to see the increased productiveness by converting:
>>>
>>> FunctionExpression => function FunctionSignature Block
>>>
>>>
>>> To:
>>>
>>> FunctionExpression => async function FunctionSignature Block
>>>
>>>
>>> And the equivalent for the grammar for await. Probably:
>>>
>>> UnaryExpression =>
>>>   await RealUnaryExpression
>>>
>>> Or something
>>>
>>>
>>>
>>> On Thu, Dec 7, 2017 at 4:18 PM, Naveen Chawla <naveen.chwl at gmail.com>
>>> wrote:
>>>
>>>> You've lost me. It's not intended to add logic. It's a replacement for
>>>> callbacks, and makes expressing async data flows simpler & more manageable,
>>>> allowing more complex async data flows to be expressed more quickly and be
>>>> less prone to bugs. The `autoasync` `background` concept makes this even
>>>> more so. Retaining all the functionality, increasing rate of productivity.
>>>> That's the whole point.
>>>>
>>>> On Thu, 7 Dec 2017 at 20:36 Florian Bösch <pyalot at gmail.com> wrote:
>>>>
>>>>> On Thu, Dec 7, 2017 at 2:34 PM, Naveen Chawla <naveen.chwl at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> How has using async await made you type more? Can you give an
>>>>>> example? I suspect you're not using it in the way it was intended to be
>>>>>>
>>>>>
>>>>> See example OP pasted. It's nothing but async/await. It doesn't add
>>>>> any semantic, syntactic or logic thing to the code. It could be 4
>>>>> white-spaces and you'd not loose any meaning.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180212/a2f51067/attachment-0001.html>


More information about the es-discuss mailing list