Igor Baklan (2017-01-03T10:52:36.000Z)
I looks like it would be nice to have ``async``-block which might be alias
to ``async``-lambda immediate invocation, so that:

```js
var promise = async { /*some statements with await*/ };
```
<==>

```js
var promise = (async () => { /*some statements with await*/ }) ();
```

and

```js
var promise = async ( /*some statements with await*/ );
```
<==>

```js
var promise = (async () => ( /*some expression with await*/ )) ();
```

Then it can gave some convenience in writing some semi-async function, like
for example parallel async batch processing, which might look like:

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async {
        const content = await readContent(item);
        await writeContent(item + ".bak", content);
      }
    )
  }
  return Promise.all(tasks)
}
```

or like

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  }
  return Promise.all(tasks)
}
```

of course this simplistic case can be rewritten without ``async``-block
like:

```js
const backupBatch = (batch) => {
  return Promise.all(
    batch.map(
      async (item) => (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  );
}
```
However I believe this not reduce usefulness of initial ``async``-block
construction.

Also it should be mentioned that this idea "is't new", something very
similar I saw in [[async-do]](/topic/support-syntax#content-5) comment.

And finally, if this construct will  be introduced, it will provide some
nice symmetry - of whether you put async keyword in function header
definition, or at the very beginning of its body, like:

```js
const asyncFunc = async (/*args*/) => {/*function body with await-s*/};
```
<==>
```js
const asyncFunc = (/*args*/) => { return async {/*function body with
await-s*/} };
```
<==>
```js
const asyncFunc = (/*args*/) => ( async {/*function body with await-s*/} );
```

And
```js
const asyncFunc = async (args) => (some_async_expression);
```
<==>
```js
const asyncFunc = (args) => async (some_async_expression);
```

By the way parentheses here is essential, since ``async x => x`` != ``async
(x => x)``, cause first evaluates into async-function, while the second
should be evaluated into completed promise which value is ``sync`` function
``(x => x)``.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170103/82bfc1ac/attachment.html>
io.baklan at gmail.com (2017-01-03T21:34:18.940Z)
I looks like it would be nice to have ``async``-block which might be alias
to ``async``-lambda immediate invocation, so that:

```js
var promise = async { /*some statements with await*/ };
```
<==>

```js
var promise = (async () => { /*some statements with await*/ }) ();
```

and

```js
var promise = async ( /*some statements with await*/ );
```
<==>

```js
var promise = (async () => ( /*some expression with await*/ )) ();
```

Then it can gave some convenience in writing some semi-async function, like
for example parallel async batch processing, which might look like:

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async {
        const content = await readContent(item);
        await writeContent(item + ".bak", content);
      }
    )
  }
  return Promise.all(tasks)
}
```

or like

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  }
  return Promise.all(tasks)
}
```

of course this simplistic case can be rewritten without ``async``-block
like:

```js
const backupBatch = (batch) => {
  return Promise.all(
    batch.map(
      async (item) => (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  );
}
```
However I believe this not reduce usefulness of initial ``async``-block
construction.

Also it should be mentioned that this idea "isn't new", something very
similar I saw in [[async-do]](/topic/support-syntax#content-5) comment.

And finally, if this construct will  be introduced, it will provide some
nice symmetry - of whether you put async keyword in function header
definition, or at the very beginning of its body, like:

```js
const asyncFunc = async (/*args*/) => {/*function body with await-s*/};
```
<==>
```js
const asyncFunc = (/*args*/) => { return async {/*function body with await-s*/} };
```
<==>
```js
const asyncFunc = (/*args*/) => ( async {/*function body with await-s*/} );
```

And
```js
const asyncFunc = async (args) => (some_async_expression);
```
<==>
```js
const asyncFunc = (args) => async (some_async_expression);
```

By the way parentheses hear (in ``async(...)``) might be essencial, for example for following case: ``async x => x`` != ``async
(x => x)``, cause first evaluates into async-function, while the second should be evaluated into completed promise which value is ``sync`` function ``(x => x)``.
io.baklan at gmail.com (2017-01-03T11:00:39.047Z)
I looks like it would be nice to have ``async``-block which might be alias
to ``async``-lambda immediate invocation, so that:

```js
var promise = async { /*some statements with await*/ };
```
<==>

```js
var promise = (async () => { /*some statements with await*/ }) ();
```

and

```js
var promise = async ( /*some statements with await*/ );
```
<==>

```js
var promise = (async () => ( /*some expression with await*/ )) ();
```

Then it can gave some convenience in writing some semi-async function, like
for example parallel async batch processing, which might look like:

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async {
        const content = await readContent(item);
        await writeContent(item + ".bak", content);
      }
    )
  }
  return Promise.all(tasks)
}
```

or like

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  }
  return Promise.all(tasks)
}
```

of course this simplistic case can be rewritten without ``async``-block
like:

```js
const backupBatch = (batch) => {
  return Promise.all(
    batch.map(
      async (item) => (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  );
}
```
However I believe this not reduce usefulness of initial ``async``-block
construction.

Also it should be mentioned that this idea "is't new", something very
similar I saw in [[async-do]](/topic/support-syntax#content-5) comment.

And finally, if this construct will  be introduced, it will provide some
nice symmetry - of whether you put async keyword in function header
definition, or at the very beginning of its body, like:

```js
const asyncFunc = async (/*args*/) => {/*function body with await-s*/};
```
<==>
```js
const asyncFunc = (/*args*/) => { return async {/*function body with await-s*/} };
```
<==>
```js
const asyncFunc = (/*args*/) => ( async {/*function body with await-s*/} );
```

And
```js
const asyncFunc = async (args) => (some_async_expression);
```
<==>
```js
const asyncFunc = (args) => async (some_async_expression);
```

By the way parentheses hear (in ``async(...)``) might be essencial, for example for following case: ``async x => x`` != ``async
(x => x)``, cause first evaluates into async-function, while the second should be evaluated into completed promise which value is ``sync`` function ``(x => x)``.
io.baklan at gmail.com (2017-01-03T10:55:42.578Z)
I looks like it would be nice to have ``async``-block which might be alias
to ``async``-lambda immediate invocation, so that:

```js
var promise = async { /*some statements with await*/ };
```
<==>

```js
var promise = (async () => { /*some statements with await*/ }) ();
```

and

```js
var promise = async ( /*some statements with await*/ );
```
<==>

```js
var promise = (async () => ( /*some expression with await*/ )) ();
```

Then it can gave some convenience in writing some semi-async function, like
for example parallel async batch processing, which might look like:

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async {
        const content = await readContent(item);
        await writeContent(item + ".bak", content);
      }
    )
  }
  return Promise.all(tasks)
}
```

or like

```js
const backupBatch = (batch) => {
  var tasks = [];
  for (let item of batch) {
    tasks.push(
      async (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  }
  return Promise.all(tasks)
}
```

of course this simplistic case can be rewritten without ``async``-block
like:

```js
const backupBatch = (batch) => {
  return Promise.all(
    batch.map(
      async (item) => (
        await writeContent(item + ".bak", await readContent(item));
      )
    )
  );
}
```
However I believe this not reduce usefulness of initial ``async``-block
construction.

Also it should be mentioned that this idea "is't new", something very
similar I saw in [[async-do]](/topic/support-syntax#content-5) comment.

And finally, if this construct will  be introduced, it will provide some
nice symmetry - of whether you put async keyword in function header
definition, or at the very beginning of its body, like:

```js
const asyncFunc = async (/*args*/) => {/*function body with await-s*/};
```
<==>
```js
const asyncFunc = (/*args*/) => { return async {/*function body with await-s*/} };
```
<==>
```js
const asyncFunc = (/*args*/) => ( async {/*function body with await-s*/} );
```

And
```js
const asyncFunc = async (args) => (some_async_expression);
```
<==>
```js
const asyncFunc = (args) => async (some_async_expression);
```

By the way parentheses here is essential, since ``async x => x`` != ``async
(x => x)``, cause first evaluates into async-function, while the second

should be evaluated into completed promise which value is ``sync`` function
``(x => x)``.