However... in that thread, the proposal I accidentally duplicated got shot down early and other alternatives were discussed.
I don't quite agree with the mentioned disadvantages of that proposal though:
Well but async
is already doing "magic": It turns every return value into a promise, regardless of the function's contents. And await
magically determines, if the passed expression actually is a Promise.
The proposed sync
keyword (or await
block in the other thread) would do the same but additionally await
every expression inside the code block (sequentially in the order of expression evaluation).
Yeah, well "appetite" is something very subjective
But I agree that in web programming await
is always "important enough to being explicitly annotated"
It's just for batch-style scripts that this would really make things more readably IMO. (For code intended for browsers it might even make sense to prohibit the proposed keyword via eslint
.)
Consider node's fs.readFile
vs fs.readFileSync
for example: I've always found it quirky to have a second method that essentially does the same as the first, only that one returns a Promise and the other actually blocks the execution until the file has been read.
But I understand why they additionally introduced fs.readFileSync
- for the same reason I'm proposing sync
: To not have thousands of await
keywords cluttering batch-style scripts.