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

T.J. Crowder tj.crowder at farsightsoftware.com
Sun Dec 3 11:43:28 UTC 2017


I understand the motivation, but I have to disagree with the proposal
for multiple reasons:

1. It adds too much confusion to the existing syntax.

2. If the calling code needs to call one of these new-style `await`
functions and access its promise (rather than `await`ing it), it
doesn't have a way to do that; `async`/`await` doesn't have full
coverage of all patterns (yet, possibly never), sometimes you still
need to access the actual promise (for instance, to feed into
`Promise.all` or `Promise.race`). (Obviously you could add something
to make it possible to access the promise.)

3. Having a clear indicator in the source saying where the async
boundaries are is useful for code correctness. With the new syntax, I
have no idea of the temporal sequence of this code:

```js
let x = foo();
let y = bar();
```

...without going and looking at the declarations of `foo` and `bar`.
With current syntax, it's clear when there's an async break in the
flow. I think the phrase is "prefer explicit to implicit" or something
like that.

-- T.J. Crowder


More information about the es-discuss mailing list