2 ms·
Why not JS/C#/Python style `await foo()` is discussed here: https://paper.dropbox.com/doc/Await-Syntax-Write-Up-t9NlOSeI4RQ8AINsaSSyJ https://paper.dropbox.com
by Macha 7y ago
Why not JS/C#/Python style `await foo()` is discussed here:
https://paper.dropbox.com/doc/Await-Syntax-Write-Up-t9NlOSeI4RQ8AINsaSSyJ https://paper.dropbox.com/doc/Await-Syntax-Write-Up-t9NlOSeI...
Main points against:
1. Interacts poorly with the ? operator for propagating errors. You'd need to do (await foo())?
2. Chains poorly. `await foo().bar().baz()`
- a. What are you awaiting? foo() or foo().bar().baz()
- b. What if you wanted to await foo().bar()? (await foo().bar()).baz() is messy.
- c. What if you wanted to chain promises? Like httpRequest.send().body() . In many libraries such as Python's requests, the first returns a future for a response with headers and only a later call waits until the body is returned. `await (await httpRequest.send()).body()`
Why not .await() or .await!():
https://boats.gitlab.io/blog/post/await-decision/ https://boats.gitlab.io/blog/post/await-decision/