4 ms·
async is huge, and I'm worried about future similar changes. Suddenly "x.y" means member access.. except for x.await, which has a magic different meaning I sti
by CJefferson 7y ago
async is huge, and I'm worried about future similar changes.
Suddenly "x.y" means member access.. except for x.await, which has a magic different meaning I still don't really understand. And adding 'await' to a function declaration magicly mangles it in various ways.
- hamaluik 7y agoIf you’re interested, I found this blog post [1] a really solid introduction to what async / await are in Rust, and how they’re used. [1] https://os.phil-opp.com/async-await/ https://os.phil-opp.com/async-await/
- red75prime 7y agoYou can always write `fn foo() -> impl Future` and mangle your code manually, using future combinators, though.
- roca 7y agoHonestly I haven't found those things to be problems at all. ".await" really isn't confusing. I think you meant "adding 'async'" to a function declaration --- it seems fine, but I personally don't use it.
- CJefferson 7y agoThe .await is another thing one needs to teach, and fairly early on so that people reading code examples don't get confused by where the "await" member of structures are. It just seems like a really bizarre break in what was fairly clean notation.
- majewsky 7y agoFor me, it helps that ".await" appears as a keyword because of syntax highlighting. It is an odd syntax, but the alternative way of making await a prefix operator instead of a postfix operator would have been way worse for readability. Compare let bar = list_foos().await.first().list_bars().await.first(); vs. let bar = (await (await list_foos()).first().list_bars()).first();
- ragnese 7y agoI do agree. The syntax they chose was not my favorite option. I wish they at least had put the stupid parentheses, so you can think of awaiting as an operation that the compiler "magically" puts on Futures in async contexts. I know that's not technically right, but it still seems a better approximation to reality.