# Await Syntax Discussion Summary

**URL:** <https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914>\
**Category:** language design\
**Created:** [April 29, 2019, 9:55pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914 "2019-04-29T21:55:54Z")\
**Posts on this page:** 20\
**Page:** 9

<div class="post-metadata">

**Author:** ![Cazadorro](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cazadorro/32/4551_2.png) [@Cazadorro](https://internals.rust-lang.org/u/Cazadorro)\
**Post date:** [May 3, 2019, 1:42pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/171 "2019-05-03T13:42:30Z")

</div>

Multiple people have already talked about the persistence of **await chaining** , and where it would be applicable in real code. People already inclined to use it found in their projects one could use it a lot. For people who want it, it now is clear they would use it enough for it to be worth it.

Unfortunately if you want to get the communities collective conclusion on this, you're going to have to read 162 posts here, some more posts in the [poll thread](https://internals.rust-lang.org/t/async-await-syntax-straw-poll/9954/1) and related new threads (like [pipelining](https://internals.rust-lang.org/t/idea-universal-pipelining-a-k-a-making-await-generic/9973)) **plus** some reddit comments in the reddit sister thread and poll thread.

If you haven't at least read everything here, you've undoubtedly missed a significant amount of discussion. The big issue is that bringing these issues back up with out back-referencing what has already been discussed is counter productive and just brings us back in circles. Please do not post in these threads with out reading the full context, I just went through the entire thread _again_ to find these links, all of them pertain to this issue. You are not the first one to bring this up, and it is entirely unfair to bring them up again, disregarding previous discussion, and previous counter points.

This is a list _just from this thread alone_. There are others on reddit and in the other related threads that are also related.

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/65):
>
> Has the language team (or anyone else) carried out an experiment to convert existing code to async/await using one or more of the proposed syntaxes? This is probably a lot of work to do, but might be worth it in this specific case in order to find out how it actually feels to use each of these syntaxes. e.g., It might turn out that await? foo() actually makes a lot of sense and that the value of chaining is less than one thought.

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/66):
>
> Small-ish experiments has been conduced with real code on the [https://github.com/rust-lang/rust/issues/57640](https://github.com/rust-lang/rust/issues/57640) issue.

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/69):
>
> Thanks, but that link isn’t particularly useful unless you’re willing to sift through the ~500 comments in that issue. Were there any interesting conclusions drawn from the experiments that can be summarized?

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/70):
>
> This knowingly adds technical debt, eventual churn, and obsoletes existing documentation. In particular, I don’t expect things to change in 2 years time. The same arguments will be had again and again. For try! it was socially costly and it still made things obsolete. One notable difference here is that try! is a user space macro whereas await! cannot be. It must be implemented in the compiler which makes the technical debt that much worse. It is not uncontroversial. await!(expr) is a prefi…

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/86):
>
> Speaking from some experience with async/await in C#, my 2 cents on a prefix syntax: Things like (await Foo()).Bar() are reasonably common and somewhat annoying, but you don’t run into that case all the time. There’s also some argument to be made that the forced parentheses highlight the actual control flow. I agree that (await foo())? is too unergonomical for this very common usecase. In C#, all futures are the equivalent of Result\<T, Exception\>. You can query that by hand, but await auto…

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/127):
>
> If you want to see how some of the proposed await syntaxes would look like in the context of a more substantial piece of code, check out the [await-syntax](https://github.com/inejge/await-syntax) repo. It (presently) contains the source of a rather async-heavy utility from Google’s Fuchsia, translated to several syntaxes from the lang team’s writeup (two prefix and two postfix). While adapting the code, I’ve noticed that a) as expected, a lot of await calls interact with ?, b) there were not really many opportunites to chain awaits (fo…

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/133):
>
> Your experience is different from mine, then. I’ve wanted to chain after await decently frequently, and have been consistently say about its fixity every time. I put a few examples in [https://github.com/rust-lang/rust/issues/57640#issuecomment-457457727](https://github.com/rust-lang/rust/issues/57640#issuecomment-457457727); to excerpt a few here: id = id ?? (await this.storageCoordinator.GetDefaultWidgetAsync(cancellationToken)).Identity; var pending = (await transaction.Connection.QueryAsync\<EventView\>(command)).ToList(); This direction happened in the issu…

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/137):
>
> One particular examples from [https://github.com/inejge/await-syntax/blob/master/bin/wlan/wlantool/src/main.rs](https://github.com/inejge/await-syntax/blob/master/bin/wlan/wlantool/src/main.rs) converted to use .await (replaced with .match for highlighting) (we can bikeshed formatting some other time): opts::ClientCmd::Disconnect { iface\_id } =\> { get\_client\_sme(wlan\_svc, iface\_id).match? .disconnect().match .map\_err(|e| format\_err!("error sending disconnect request: {}", e)) } I find this quite readable and it seems quite ergonomic to write as well, espec…

> [@Await Syntax Discussion Summary](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/144):
>
> As Centril mentioned, there are 17 opportunities for chaining in [that code](https://github.com/inejge/await-syntax/blob/postfix-field/bin/wlan/wlantool/src/main.rs). See how it removes the temporaries and makes it easier to follow the control flow?

---

<div class="post-metadata">

**Author:** ![burntsushi](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/burntsushi/32/279_2.png) [@burntsushi](https://internals.rust-lang.org/u/burntsushi)\
**Post date:** [May 3, 2019, 2:07pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/172 "2019-05-03T14:07:37Z")

</div>

Thanks for posting this. I hadn’t seen [https://github.com/inejge/await-syntax](https://github.com/inejge/await-syntax) before (and I was looking for something like that). That’s a testament to just how hard it is to keep up with this discussion.

Looking at that code does push me more towards a postfix syntax, particularly given the prevalence of the `context` method from failure to customize errors. That is something I perceive will become more and more common (not just from `failure`), and prefix await (even with `await?`) doesn’t really address that. e.g., Even if we have `await?`, if you’re writing `(await foo).context("an error")?` a lot, then the `await?` syntax doesn’t really help.

---

<div class="post-metadata">

**Author:** ![nikomatsakis](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nikomatsakis/32/5410_2.png) [@nikomatsakis](https://internals.rust-lang.org/u/nikomatsakis)\
**Post date:** [May 3, 2019, 2:39pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/173 "2019-05-03T14:39:43Z")

</div>

> [@burntsushi](#):
>
> Thanks for posting this. I hadn’t seen [https://github.com/inejge/await-syntax](https://github.com/inejge/await-syntax) before (and I was looking for something like that). That’s a testament to just how hard it is to keep up with this discussion.

I do want to commend @inejge for preparing that repository as well. I've been following along with this thread and I've noticed that, along the way, a number of people have made real efforts to try and help people step back and help everyone gain overall perspective, whether that be through [the straw poll](https://internals.rust-lang.org/t/async-await-syntax-straw-poll/9954/16), summary posts/gists like [this one by @HeroicKatora](https://gist.github.com/HeroicKatora/3dec0f34483c285cb8e33bb4dd9e3d9f) (which also lists a ton of summary posts itself!), or even just careful exposition of examples. I just wanted to say a big ❤ "thank you" ❤ to such folks. (As someone who hadn't been following the debate in detail until recently, these kinds of things were also super helpful to me.)

---

<div class="post-metadata">

**Author:** ![Mr\_Byte](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mr_byte/32/334_2.png) [@Mr\_Byte](https://internals.rust-lang.org/u/Mr_Byte)\
**Post date:** [May 3, 2019, 5:38pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/174 "2019-05-03T17:38:57Z")

</div>

I’ve written a reasonably sized, non-trivial codebase that currently uses futures on stable that’s somewhere in the 5000 SLOC range. Async/await is something I’ve been very eagerly awaiting because in my own experiments in converting that codebase over to nightly with the current await!() macro, I dropped around 600 SLOC off the total size of the project and wound up with code that I feel is much easier to follow and reason about. So I’ve been mulling over the options presented and after looking at the repo that contains code converted to four of the proposed syntaxes, I’ve come down to being torn between prefix with mandatory delimiters and postfix method syntax.

For prefix with mandatory delimiters, I feel like it’s more obvious to me immediately upon glancing at the code that something special is going on. It definitely feels like a control-flow construct and I know my function is going to be doing something special at that point (yielding execution until some time later). I also like the potential that it becomes easier to nest arbitrary expressions inside the await block, such as a match statement that could be selecting from one of several boxed futures that need to be awaited upon, but I’m not entirely sure how useful that would be. All-in-all I like the way it stands out to me as a reader.

As for postfix method syntax, I find it incredibly ergonomic and it flows well with the typical pattern of the language. It was mentioned that it flows well with error combinators that many error handling libraries currently provide and may provide more of in the future. It feels like the most ergonomic option for the way rust is typically written with long chains of methods. It feels less obvious upfront that something special is happening, but at the same time I would argue the fact that the function is marked with an “async” modifier already indicates something special is going on to the reader and would act as the launch point for someone wishing to search for more information on the topic of async/await. So I feel my concern over obviousness is alleviated mostly by this fact.

When I went into thinking about this discussion and my own codebase I was very heavily leaning towards a prefix syntax, especially given prior experience with C#, JavaScript, and Python’s async/await support. With more recent experience with Kotlin’s coroutines, which have a method called await() to suspend the coroutine, I don’t feel like postfix method syntax is all that weird anymore.

In the end I would say that I’m leaning more in favor of postfix method syntax now because of the way it fits the language ergonomics better and alleviates the need for a special await? operator just for error handling. It provides one way to do something that fits with the language and as mentioned earlier, the more I reason it through, the less I feel it’ll be a discoverability issue for people new to the language thanks to other aspects of the async/await design in Rust.

---

<div class="post-metadata">

**Author:** ![aidancully](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aidancully/32/5532_2.png) [@aidancully](https://internals.rust-lang.org/u/aidancully)\
**Post date:** [May 3, 2019, 5:50pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/175 "2019-05-03T17:50:28Z")

</div>

I’m wary of wading into a big discussion… I’ve read the whole discussion so far, watched the presentation @withoutboats [linked to](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/89), and still want to contribute, sorry.

First, put me in the postfix-await camp. Prefix-await currently exists predominantly (exclusively?) in languages that embrace exceptions as part of their flow-control. The drawbacks of prefix-based await – in particular around error handling – are not as much of a problem when using exceptions. We don’t use prefix `try`, anymore, even though that’s more familiar to most users than postfix `?`, because we use more explicit error handling than exception-oriented languages, and we think about errors more in the context of what generates them, so keep the related construct (the thing that raises the error, and the thing that allows us to read past the error) syntactically close. The same argument applies to `await` (IMHO): we think of the thing we’re waiting for when we decide to wait, so keep those constructs lexically close.

Second, I think postfix-await can work differently with for loops than what I’ve seen discussed so far, and provides a reasonable approach to handling `?` against iterators:

```rust
for await foo in bar

```

would be consistent with postfix-`await` if you consider `await` to modify the `for` loop, rather than the item being awaited. That is, the parse tree would be more like: `(("for await") (foo) "in" (bar)))` than it would `("for" ("await" (foo)) "in" (bar))`.

This suggests using space as an `await` separator, rather than `.`? (Makes it much clearer that something important is going on than the field-access-syntax of `.`.) Or else `for.await foo in bar` if you stick to `.`? But either idea extends naturally to

```rust
for? var in iterable {
}

```

and indicates more clearly that the novel syntax is modifying the loop itself, rather than modifying the variable bound in the body.

---

<div class="post-metadata">

**Author:** ![kjeremy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kjeremy/32/5492_2.png) [@kjeremy](https://internals.rust-lang.org/u/kjeremy)\
**Post date:** [May 3, 2019, 7:14pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/176 "2019-05-03T19:14:44Z")

</div>

What I like about `await` in other languages is how it stands out so you know exactly where asynchronicity is happening (note that this is different from control flow). I find the postfix notation loses this distinction and it’s only by noticing that the function is `async` that I know to scan for postfix `await`.

---

<div class="post-metadata">

**Author:** ![JeanMertz](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jeanmertz/32/4536_2.png) [@JeanMertz](https://internals.rust-lang.org/u/JeanMertz)\
**Post date:** [May 3, 2019, 8:15pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/177 "2019-05-03T20:15:08Z")

</div>

> [@kjeremy](#):
>
> What I like about `await` in other languages is how it stands out so you know exactly where asynchronicity is happening

My hope is that with the safety checks we have in Rust, and a good async/await implementation, that asynchronicity becomes “just another concept” that’s part of the language.

It has no need to stand out, because its usage — and more importantly, its potential surprises — doesn’t stand out.

Having said that, while I agree with @Mr_Byte that the postfix syntax has grown on me, I am still troubled by the special place it would have in the language either as a special field, or method (something the prefix with required delimiters would not have, except that it also requires `await?`, which isn’t great either)

---

<div class="post-metadata">

**Author:** ![bmisiak](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bmisiak/32/7372_2.png) [@bmisiak](https://internals.rust-lang.org/u/bmisiak)\
**Post date:** [May 3, 2019, 9:09pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/178 "2019-05-03T21:09:03Z")

</div>

Contributing because I still see a lof of arguments in favor of a sigil.

# No budget for sigils

Rust is already busy with `'`, `&'a`,`<'_>`. Contrast this with the most popular languages out there, like JavaScript, which has none of that. They are very discouraging for novices taking a glance at the language, as **they require googling or reading the documentation** to understand, which is very undesirable. Given that Rust's mission is to empower everyone (coming from those languages) to build efficient and safe software, I think we have no budget left for more sigils. We need to keep Rust's appeal to increase our [mere 3.2% market share.](https://insights.stackoverflow.com/survey/2019#technology-_-programming-scripting-and-markup-languages)

# Prefix

If we go with prefix, I believe the most approachable syntax is **mandatory delimiters** (`await { future }?`). It avoids all the pitfalls of `await future` and has **no ambiguity for people who have not read Rust's documentation** (unlike `await?`, which I see as a crutch that does not work well for nested futures and still requires a documentation lookup, like a sigil would). Here is [https://github.com/inejge/await-syntax/](https://github.com/inejge/await-syntax/) with modified syntax highlighting:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/b/bf2ce5e63c85efa160fe5fbe90b84f2408f0ecc2.png)

# Postfix

I do like the arguments favoring a postfix syntax and actually prefer it, as long as it is not a sigil.

- `f.await{}?`
- `f.await()?`
- `f.await?`
- `f.await!()?`
- `f.await!?`
- `f..await?`
- `f.await{}?`

All look acceptable to me. My preferences indicate control flow shenanigans:

```rust
let result1 = future.await{}?.do_more().await{};

```

```rust
let result2 = future.await!()?.do_more().await!();

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/5/531f7914fcda8e55dd38426c8c7625dcff212317.png)

Personally, `await{}?` at the end of the line is more visible to me than the prefix version.

---

<div class="post-metadata">

**Author:** ![whitfin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/whitfin/32/5470_2.png) [@whitfin](https://internals.rust-lang.org/u/whitfin)\
**Post date:** [May 3, 2019, 9:23pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/179 "2019-05-03T21:23:33Z")

</div>

I wrote a little further up, but want to circle back as it’s less of an impulsive response given I’ve had a few days to think about it. There’s a lot going on in this thread and people are making good arguments in favour of every suggestion, however there are some specific suggestions which I strongly disagree with.

The first is the sigil form suggested. This is not specifically because I am against the idea, but because there is no obvious symbol to use for this form. The `?` operator for something which could have failed is a logical choice. I have (so far) seen `@`, `!` and `#` suggested in this thread and none of those make any sense with reference to async/await (at least to me). Regardless of if I’m missing something or not, the fact I might be represents that it will be very non-obvious to other users as well. If we do decide on sigils, it should only lead to yet another discussion of which symbol to use - it should not be chosen lightly. This extra overhead makes me against going this route (at least for now).

The other form is the field syntax. If you look at the code `foo.await`, it’s entirely non-obvious that this could take potentially forever to return. It’s too much of a deviation from what that syntax already represents. Conceptually, once someone has explained it to you, it’s not complicated. However I imagine most people will leave with a “that’s kinda gross” feeling. Do not forget that this is meant to be friendly for everyone, including newcomers and intermediates, not only those who are deeply involved with Rust. Not only do I feel it bad in this case, it would also set precedence for a pattern we might not want to continue with.

My initial response was to simply see the syntax of `foo.await()` come into play. I don’t see why async/await should be considered anything other than a function call from a developer perspective. The existing `Future` in the external crates literally has a `foo.wait()` which simply polls continuously. The biggest argument I’ve seen for this (disregarding arguments against postfix in general) is that it’s non-obvious that it’s doing something asynchronous. I understand this point of view, but would like to point out that just because you have a `Future` does not technically guarantee you’re doing something asynchronous.

I still agree with all of this, except that the extra couple of days have given me more time to reflect. As such, I have changed my mind to favour `foo.await!()`. It provides a very obvious syntax that can be used for similar features in future, as it’s familiar as it’s a combination of two existing things - macros and functions. Rather than caring that “it’s obvious it’s doing something asynchronous”, I now prefer this syntax because it’s obvious that it’s builtin, in the same way we all use `println!` rather than `println`. I believe that this syntax strikes a balance between familiarity and ergonomics, and has the added advantage that we’re also deciding the syntax for other features down the road. There are no new symbols required in the language, and there’s no real new concept that you have to learn to move to asynchronous programming.

I do still feel it’s a shame that we’re likely to go postfix rather than prefix, as I do like `await foo()`, but at this point I haven’t seen anything close to compelling for the prefix case which still solves the initial problem.

---

<div class="post-metadata">

**Author:** ![160R](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/160r/32/9502_2.png) [@160R](https://internals.rust-lang.org/u/160R)\
**Post date:** [May 3, 2019, 9:33pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/180 "2019-05-03T21:33:25Z")

</div>

> [@whitfin](#):
>
> The `?` operator for something which could have failed is a logical choice. I have (so far) seen `@` , `!` and `#` suggested in this thread and none of those make any sense with reference to async/await (at least to me).

`@` has a lot of sense:

1. It looks like spiral which could be associated with looping which on fact is done under the hood
2. It has letter "a" inside which could be seen as short for "await"

---

<div class="post-metadata">

**Author:** ![karidhassan22](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@karidhassan22](https://internals.rust-lang.org/u/karidhassan22)\
**Post date:** [May 3, 2019, 9:46pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/181 "2019-05-03T21:46:42Z")

</div>

I find it funny that in [https://github.com/inejge/await-syntax/](https://github.com/inejge/await-syntax/), all four variants end up with exact 568 lines of code, despite the claim that prefix `await`s are verbose and postfix `await`s save you temporary variables, more clean, etc. In my opinion, this is the evidence that postfix `await`s are not much too useful in practice.

---

<div class="post-metadata">

**Author:** ![asa-z](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/asa-z/32/6771_2.png) [@asa-z](https://internals.rust-lang.org/u/asa-z)\
**Post date:** [May 4, 2019, 3:03am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/182 "2019-05-04T03:03:48Z")

</div>

Lines of code do not totally indicate verbosity in this case, as

```rust
get_client_sme(wlan_svc, iface_id).await()?;
                .disconnect().await()
                .map_err(|e| format_err!("error sending disconnect request: {}", e))

```

has the same number of lines of code as

```rust
let sme = (await get_client_sme(wlan_svc, iface_id))?;
let disconnected = await sme.disconnect()
         .map_err(|e| format_err!("error sending disconnect request: {}", e))

```

but the former is much clearer and less verbose.

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [May 4, 2019, 4:32am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/183 "2019-05-04T04:32:04Z")

</div>

> [@kjeremy](#):
>
> What I like about `await` in other languages is how it stands out so you know exactly where asynchronicity is happening (note that this is different from control flow). I find the postfix notation loses this distinction and it’s only by noticing that the function is `async` that I know to scan for postfix `await` .

This is exactly the argument that was made about `try!(foo)` vs `foo?`: That the former stands out. However, in retrospect, that seems to not to have been an issue. Is there something about `await foo` vs `foo.await` that would make this more of a problem than exists with `?`?

I'll note, also, that you already commonly need to scan postfix for `?` in `async`, so I'd rather scan postfix for `await` too, rather than need to scan both prefix _and_ postfix.

---

<div class="post-metadata">

**Author:** ![skade](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/skade/32/3333_2.png) [@skade](https://internals.rust-lang.org/u/skade)\
**Post date:** [May 4, 2019, 7:04am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/184 "2019-05-04T07:04:44Z")

</div>

Phew, I honestly don’t see how the former is clearer then the last. The first one has a whole complex chain in a function call, which I’d avoid in _any_ case.

I’d agree though that number of lines are not a good metric here, they should be spent for clarity and more LoC might be better and more lightweight if we’re talking about 2 separate actions.

---

<div class="post-metadata">

**Author:** ![skade](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/skade/32/3333_2.png) [@skade](https://internals.rust-lang.org/u/skade)\
**Post date:** [May 4, 2019, 7:21am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/185 "2019-05-04T07:21:08Z")

</div>

> [@karidhassan22](#):
>
> I find it funny that in [https://github.com/inejge/await-syntax/](https://github.com/inejge/await-syntax/), all four variants end up with exact 568 lines of code, despite the claim that prefix `await` s are verbose and postfix `await` s save you temporary variables, more clean, etc. In my opinion, this is the evidence that postfix `await` s are not much too useful in practice.

I agree, it also has very little chaining situations and they would not suffer from a temporary variable. (like in the `await!` version).

As an example: [Comparing master...postfix-method · inejge/await-syntax · GitHub](https://github.com/inejge/await-syntax/compare/postfix-method?diff=split#diff-21ccda933f853d0eeb36a97fc8b060d9L236)

---

<div class="post-metadata">

**Author:** ![cenwangumass](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cenwangumass/32/5112_2.png) [@cenwangumass](https://internals.rust-lang.org/u/cenwangumass)\
**Post date:** [May 4, 2019, 7:24am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/186 "2019-05-04T07:24:18Z")

</div>

First, please don’t assume other people don’t understand the context as you do. These statistics were calculated back when the syntax issue was still discussed on Github. I’ve been closely following this problem.

Second, my two points are misunderstood. I’m not saying there isn’t opportunity to use await chains. I’m arguing if you favor postfix await, you can always find some code examples and show its benefits. However, these examples are not necessarily representative. I’m showing statistics for ? chains, which people can freely use chain or not. The result suggests there is only very rare usage of such feature in many popular Rust project. I doubt the same story may go for await chain, if postfix await is chosen.

Second, when we pick some code examples to show await chain advantages, we act as if the code is forever fixed / won’t be changed in the future. Apparently, this is untrue. Today’s nice await chains could be more inconvenient than prefix await if you refactor the code or the demand changes.

---

<div class="post-metadata">

**Author:** ![najamelan](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/najamelan/32/3162_2.png) [@najamelan](https://internals.rust-lang.org/u/najamelan)\
**Post date:** [May 4, 2019, 9:13am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/187 "2019-05-04T09:13:49Z")

</div>

> [@inejge](#):
>
> Result\<StructContainingBoxedFuture, ...\>

This would only be a problem if someone also implemented `Future` for `Result`. Otherwise the following is entirely unambiguous:

```rust
let result = Result<StructContainingBoxedFuture, …>;
await result?;

```

And even if you have a type which implements both `Future` and `std::ops::Try`, it could still be decided that operator precedence breaks the tie before you have to put parenthesis.

Just to clarify, I'm not saying this because I favor prefix, I just feel the implications of prefix are not very clear, and it's problems seem overestimated. Just like the compiler can automatically deref, it can check several ways of combining the operates in a statement before bailing with an error. If there is only one possible way to combine them into a valid expression, we're good!

The method call on a future outcome is a bigger problem. That's why I do think postfix is a good idea, but not for `?` operator.

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [May 4, 2019, 2:05pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/188 "2019-05-04T14:05:30Z")

</div>

As a member of wg-grammar (but not speaking on behalf of the wg), I’d just like to insert:

I’d very much like it if we don’t consider making the parse tree depend on type checking. It doesn’t matter if it’s trait or concrete types; making parsing depend on types is a bad idea. It’s the reason for “the lexer hack” in C and that _parsing_ C++ is undecidable, even though the feedback there is “just” whether a name is a type or not.

Sure it’s “possible”. But then e.g. syn has to include a full type checker to parse, you need full crate dependency graph context to parse, etc. Parsing should, as much as is reasonable, stay a separate stage from type checking, and the parse tree shouldn’t be rewritable based on type checking either.

---

<div class="post-metadata">

**Author:** ![vadimcn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/vadimcn/32/2789_2.png) [@vadimcn](https://internals.rust-lang.org/u/vadimcn)\
**Post date:** [May 4, 2019, 11:19pm UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/189 "2019-05-04T23:19:14Z")

</div>

> [@AGausmann](#):
>
> Maybe it’s the way to express some patterns in current stable Rust, but I’d expect futures to have combinators like the ones that `Iterator` , `Option` , and `Result` currently have in std (and the ones worked on in `futures-rs` crate).

By the way, this seems to be the only mention of future combinators in this entire thread, so I want to bump it for visibility. I think that combinators provide a fine way of chaining awaitable actions.

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [May 5, 2019, 2:06am UTC](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914/190 "2019-05-05T02:06:05Z")

</div>

Part of the reason (though obviously not the entire reason) of having `async`/`await` is to move away from having to use a whole tangle of combinators and the ownership issues that imposes. I’m not saying that they’re never a good way to write the code, but I’m pretty sure most everyone would prefer `foo()?.bar()?` to `foo().and_then(Foo::bar)?`. (And that doesn’t even work if `foo`'s error type and `bar`'s error type aren’t the exact same, and merely are `?`-convertable to the same type.)

[Previous page](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914.md?page=8)

[Next page](https://internals.rust-lang.org/t/await-syntax-discussion-summary/9914.md?page=10)
