A final proposal for await syntax

Thanks for the summary and continued work on this! I previously argued for foo.await() and foo.await!(), so seeing them leave the table is disappointing but understandable. Given all of the constraints and suggestions in the previous thread, I agree that foo.await becomes a logical frontrunner from the initial set of solutions.

Now that we have a tentative conclusion, I’d like to raise a final thought or two, even if the ship has potentially sailed:

The initial problem was one of ugliness. I personally feel that this new syntax isn’t much better in terms of ugliness, and it also introduces potential confusion for those unfamiliar with async/await (which is not a small amount of developers). I don’t think that this is much better than the syntax we’re trying to “fix”, especially when you consider that manually unpacking the result on the next line is possible. For my reference as much as anyone else’s, here’s what I see as a comparison (please correct me if mistaken):

// not checking result
let bar = await foo();
let bar = foo().await;

// using '?' operator
let bar = (await foo())?;
let bar = foo().await?;

// manual unpacking
let bar = await foo();
let bar = bar?;

As the issue at hand is pretty much just ergonomics, I believe we should officially poll to see if people prefer foo().await? or (await foo())?, rather than just do the eye test on a thread in the forums. This poll would be very specific (X vs. Y) and so it can hit the broad community without much overhead, allowing us to choose which is deemed more attractive by the majority of users. Although I do feel we should show both options with and without ?, to avoid bias. In the case the poll is split down the middle, we can then defer to the language team to break the deadlock.

Making ergonomic decisions based on a couple of forum threads where basically everyone disagrees with each other doesn’t feel like it’s a path to success, IMO. Although any replies on the internals threads are obviously valuable, I feel there may potentially be a chance that the results are skewed. For something as prominent as this feature, I don’t know if that’s something we should ignore.

tl;dr: is adding this new syntax actually better enough than what we started with to warrant doing it?

5 Likes