I really like this: it's consistent, it provides a viable chaining postfix syntax (.await
), and in less async-heavy code normal await
works the way other languages do it.
The mental model here becomes "Rust has await
syntax like other languages, but there's also a cool bit of sugar for it.". To me this is much nicer than "Rust has a new kind of await
syntax that I have to learn".
This solution of offering a prefix operator and postfix sugar also works well for a postfix macro based system! We can offer both:
await foo
foo.await!()
- (potential future extensions to allow user-defined postfix macros, which folks want anyway)
where the macro expands to the expression (and is a true macro, getting rid of the issue in the original post about this basically being not-a-real-macro and confusing).
Personally I prefer going the macro route but that's mostly because I have felt the need for postfix macros (mostly for guard let-style situations) more than I have felt the need for postfix match
or if
. Others may have differing experiences.
Overall I feel like we should be open to adding multiple syntaxes (one prefix, one postfix) here. Not as a compromise solution, but because with multiple syntaxes the mental model genuinely seems to be better: there's the syntax everyone is used to (prefix await), and a sugar syntax that's better in some scenarios. This seems to address most concerns against .await
that I've seen, and all the concerns against .await!()
from boats' post. We still have to pick one postfix syntax, but it feels like the outcome would be more agreeable to everyone, and have fewer downsides.