Support () => {}() syntax?

Kevin Smith zenparsing at gmail.com
Fri Sep 30 13:10:13 UTC 2016


Ideally there will be an `async` version of do expressions, which evaluate
to a promise:

```
let promise = async do {
  await something();
};
```

(BTW, if we get such a thing, we might not really need
top-level-module-await...)

On Fri, Sep 30, 2016 at 2:39 AM Olivier Lalonde <olalonde at gmail.com> wrote:

> Do "do expressions" support the "await" keyword?
>
> On Thu, Sep 29, 2016 at 3:59 PM, Rick Waldron <waldron.rick at gmail.com>
> wrote:
>
>>
>>
>> On Thu, Sep 29, 2016 at 3:14 PM Michał Wadas <michalwadas at gmail.com>
>> wrote:
>>
>>> Similar proposal is already here, do expressions.
>>>
>>
>> Additionally...
>>
>>>
>>> On 30 Sep 2016 12:06 a.m., "Olivier Lalonde" <olalonde at gmail.com> wrote:
>>>
>>>> I occasionally write IIFE to avoid introducing `let` variables, e.g.:
>>>>
>>>> ```
>>>> const thumb = ({ width, height }) => {
>>>>   const { w, h } = (() => {
>>>>     // if either width or height is set, don't set any default
>>>>     if (Number.isInteger(width) || Number.isInteger(height)) {
>>>>       return { w: width, h: height }
>>>>     }
>>>>     return { w: 400, h: 400 }
>>>>   })()
>>>>   // ...
>>>> }
>>>> ```
>>>>
>>>
>> Why introduce the function and cognitive overhead?
>>
>> const thumb = ({ width, height }) => {
>>   const w = Number.isInteger(width) ? width : 400;
>>   const h = Number.isInteger(height) ? height : 400;
>>   // ...
>> }
>>
>>
>> Either way, `do` expressions are what you're looking for.
>>
>>
>> Rick
>>
>
> --
> - Oli
>
> Olivier Lalonde
> http://www.syskall.com <-- connect with me!
> _______________________________________________
> 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/20160930/f70c3b9e/attachment.html>


More information about the es-discuss mailing list