You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before commenting in this thread, please check #50547 and try to check that you're not duplicating arguments that have already been made there.
Notes from shepherds:
If you're new to this thread, consider starting from #57640 (comment), which was followed by three great summary comments, the latest of which were #57640 (comment). (Thanks, @traviscross!)
With all that, let's remember that Rust expressions can result in several chained methods. Most languages tend to not do that.
I'd say that languages that support extension methods tend to have them. These would include Rust, Kotlin, C# (e.g. method-syntax LINQ and various builders) and F#, although the latter heavily uses the pipe operator for the same effect.
Purely anecdotal on my part but I regularly run in to dozen+ method chained expressions in Rust code in the wild and it reads and runs fine. I haven't experienced this elsewhere.
Reacted by Pauan, chpio, Joshua Barretto, Florin and Weiwei Lin
Thank you for mentioning that. Kotlin feels more implicit because futures are eager by default. It's still however a common pattern in a deferred block to use that method to wait on other deferred blocks. I've certainly done it several times.
@cramertj Since there are 276 comments in #50547, could you summarize the arguments made there to make it easier to not repeat them here? (Maybe add them to the OP here?)
Reacted by tesuji, chpio, Akash Gurava, Tomas Sedlak, Pauan, j-k, Philipp Oppermann, kennytm, Maor Kadosh, matthieu-m and 3 more
Kotlin feels more implicit because futures are eager by default. It's still however a common pattern in a deferred block to use that method to wait on other deferred blocks. I've certainly done it several times.
maybe you should add both use cases with a bit of context/description.
Also what's with other langs using implicit awaits, like go-lang?
One reason to be in favour of a post-fix syntax is that from the callers perspective, an await behaves a lot like a function call: You relinquish flow control and when you get it back a result is waiting on your stack. In any case, I'd prefer a syntax that embraces the function-like behaviour by containing function-paranthesis. And there are good reasons to want to split construction of coroutines from their first execution so that this behaviour is consistent between sync and async blocks.
But while the implicit coroutine style has been debated, and I'm on the side of explicitness, could calling a coroutine not be explicit enough? This probably works best when the coroutine is not directly used where constructed (or could work with streams). In essence, in contrast to a normal call we expect a coroutine to take longer than necessary in a more relaxed evaluation order. And .await!() is more or less an attempt to differentiate betwen normal calls and coroutine calls.
So, after hopefully having provided a somewhat new take on why post-fix could be preferred, a humble proposal for syntax:
future(?)
or future(await) which comes with its own tradeoffs of course but seems to be accepted as less confusing, see bottom of post.
Adapting a fairly popular example from other thread (assuming the logger.log to also be a coroutine, to show what immediately calling looks like):
async fn log_service(&self) -> T {
let service = self.myService.foo(); // Only construction
self.logger.log("beginning service call")(?);
let output = service(?); // Actually wait for its result
self.logger.log("foo executed with result {}.", output)(?);
output
}
And with the alternative:
async fn log_service(&self) -> T {
let service = self.myService.foo(); // Only construction
self.logger.log("beginning service call")(await);
let output = service(await);
self.logger.log("foo executed with result {}.", output)(await);
output
}
To avoid unreadable code and to help parsing, only allow spaces after the question mark, not between it and the open paran. So future(? ) is good while future( ?) would not be. This issues does not arise in the case of future(await) where all current token can be used as previously.
The interaction with other post-fix operators (such as the current ?-try) is also just like in function calls:
async fn try_log(message: String) -> Result<usize, Error> {
let logger = acquire_lock()(?);
// Very terse, construct the future, wait on it, branch on its result.
let length = logger.log_into(message)(?)?;
logger.timestamp()(?);
Ok(length)
}
Or
async fn try_log(message: String) -> Result<usize, Error> {
let logger = acquire_lock()(await);
// Very terse, construct the future, wait on it, branch on its result.
let length = logger.log_into(message)(await)?;
logger.timestamp()(await);
Ok(length)
}
A few reasons to like this:
Compared to .await!() it does not allude to a member that could have other uses.
It follows natural precedence of calls, such as chaining and use of ?. This keeps the number of precendence classes lower and helps with learning. And function calls have always been somewhat special in the language (even though the have a trait), so that there is no expectation of user code being able to define their own my_await!() that has very similar syntax and effect.
This could generalize to generators and streams, as well as generators that expect more arguments to be provided on resumption. In essence, this behaves as an FnOnce while Streams would behave like a FnMut. Additional arguments may also be accomodated easily.
For those who have used current Futures before, this captures how a ? with Poll should have worked all along (unfortunate stabilization sequence here). As a learning step, it is also consistent with expecting a ? based operator to divert control flow. (await) on the other hand would not satisfy this but afterall the function will always expect to resume at the divergent point.
It does use a function-like syntax, though this argument is only good if you agree with me 😄
And reasons not to like this:
? appears to be an argument but it is not even applied to an expression. I believe this could be solved through teaching, as the token it appears to be applied to is the function call itself, which is the somewhat correct notion. This also positively means that the syntax is unambiguous, I hope.
More (and different) mix of paranthesis and ? can difficult to parse. Especially when you have one future returning a result of another future: construct_future()(?)?(?)?. But you could make the same argument for being able to a result of an fn object, leading to expression such as this being allowed: foobar()?()?()?. Since nevertheless I've never seen this used nor complaint, splitting into separate statements in such cases seems to be required rarely enough. This issues also does not exist for construct_future()(await)?(await)?-
future(?) is my best shot at a a terse and still somewhat concise syntax. Yet, its reasoning is grounded on implementation details in coroutines (temporarily returning and dispatching on resume), which might make it unsuitable for an abstraction. future(await) would be an alternative that could still be explainable after await has been internalized as a keyword but the argument position is a bit hard to swallow for me. It could be fine, and it is certainly more readable when the coroutine returns a result.
Interference with other function call proposals?
Your own? You need not like it, it just felt like a waste to not at least propose this terse post-fix syntax.
Reacted by chpio and Rasmus Kaj
Reacted by Alexandros Sigalas, lcnr, Tyler Reisinger, Christoph Herzog, Ryan Cumming, Tim Diekmann, Pratyush Mishra, Peter Hall, Swoorup Joshi, Gregory and 17 more
It seems it was not clear what I meant. future(?) is what was previously discussed as future.await!() or similar. Branching on a future that returns a result as well would be future(?)? (two different ways how we can relinquish control flow early). This makes future-polling (?) and result testing? orthogonal. Edit: added an extra example for this.
Branching on a future that returns a result as well would be future(?)?
Thanks for clarifying. In that case I'm definitely not a fan of it.
That means that calling a function which returns a Future<Output = Result<_, _>> would be written like foo()(?)?
It's very syntax-heavy, and it uses ? for two completely different purposes.
Reacted by Aurelia Molzer, Tyler Reisinger, Tim Diekmann, Peter Hall, Isaac Woods, Crystal Durham, Dmitry, Luo Jia / Zhouqi Jiang, Henrik Tudborg, Ghabriel Nunes and 5 more
At first, I was strongly on the side of having a delimiter-required prefix syntax as await(future) or await{future} since it is so unambiguous and easy to visually parse. However, I understand the proposals by others that a Rust Future is not like most other Futures from other languages, since it does not put a task onto an executor immediately, but instead is more of a control flow structure which transforms the context into what is homomorphic to a monad call chain essentially.
It makes me think that it is somewhat unfortunate that now there is a confusion in attempting to compare it to other languages with that regard. The closest analog really is the monad do notation in Haskell or the for comprehension in Scala (which are the only ones I'm familiar with off the top of my head). Suddenly, I appreciate the consideration of proposing a unique syntax, but I'm afraid that the existence of the ? operator has both encouraged and discouraged the use of other sigils with it. Any other sigil based operators next to ? make it look noisy and confusing, such as future@?, but the precedent set by having a postfix sigil operator means that another one is not so ridiculous.
I have, therefore, been convinced of the merit of the postfix sigil operator. The downside of this, is that the sigil I would've most preferred is taken by the never type. I would've preferred ! since I think that future!? would make me chuckle whenever I wrote it, and it makes the most visual sense to me to see. I suppose $ would be next, then since it is visually discernable future$?. Seeing ~ still reminds me of the early days of Rust when ~ was the prefix operator for heap allocation. It's all very personal, though, so I don't envy the final decision makers. Were I them, I would probably just go with the inoffensive choice of the prefix operator with required delimiters.
However, I understand the proposals by others that a Rust Future is not like most other Futures from other languages, since it does not put a task onto an executor immediately, but instead is more of a control flow structure which transforms the context into what is homomorphic to a monad call chain essentially.
I tend to disagree. The behaviour you mention is not a property of await, but of the surrounding async function or scope. It's not await that delays the execution of the code preceding it, but the scope that contains said code.
Probably the problem with weirdly looking @ symbol is that using it in that context was never been expected before, therefore in most fonts it's provided in so uncomfortable for us shape.
Then providing a better glyph and some ligatures for popular programming fonts (or at least for Mozilla's Fira Code) might improve situation a bit.
In all other cases, for me it don't looks that @ is so weird to cause any real problems when writing or maintaining code.
E.g. the following code uses different than @ symbol - @:
At first, I was strongly on the side of having a delimiter-required prefix syntax as await(future) or await{future} since it is so unambiguous and easy to visually parse.
Then you probably want unambiguous if { cond }, while { cond } and match { expr }...
However, I understand the proposals by others that a Rust Future is not like most other Futures from other languages
It's not true. It's actually is like most other futures from other languages. Difference between "run until first await when spawned" vs "run until first await when polled" is not that big. I know because I worked with both. If you actually think "when this difference comes to play" you will find only corner case. e.g. you will get error when creating future on first poll instead of when it's created.
They could be internally different, but they are quite the same from user perspective so it doesn't make sense to me to make a distinction here.
Difference between "run until first await when spawned" vs "run until first await when polled" is not that big.
That's not the difference we're talking about, though. We're not talking about lazy vs eager -to-first-await.
What we're talking about is that await joins the awaited Promise (JS) / Task (C#) on the executor in other languages, which was already put on the executor at construction (so was already running in the "background"), but in Rust, Futures are inert state machines until await!-driven.
Promise/Task is a handle to a running asynchronous operation. Future is a deferred asynchronous computation. People, including notable names in Rust, have made this mistake before, and examples have been linked before in the middle of these 500+ comments.
Personally, I think this mismatch of semantics is large enough to counteract the familiarity of await. Our Futures accomplish the same goal as Promise/Task, but though a different mechanism.
Anecdotally, for me when I first learned async/await in JavaScript, async was "just" something I wrote to get the await superpower. And the way I was taught to get parallelism was a = fa(); b = fb(); /* later */ await [a, b]; (or whatever it is, it's been an age since I've had to write JS). My posit is that other people's view of async lines up with me, in that Rust's semantics don't mismatch on async (give you await superpower), but on Future construction and await!.
At this point, I believe the discussion on the differences in Rust's async/Future/await semantics has run its course, and no new information is being presented. Unless you have a new position and/or insight to bring, it'd probably be best for the thread if we leave that discussion here. (I'd be happy to take it to Internals and/or Discord.)
Reacted by Pauan and Ashkan Kiani
Reacted by Psilon, Jörn Huxhorn, I60R, orthoxerox and Liv Fischer
So, we had a number of discussions about async-await at the Rust All Hands. In the course of those discussions, a few things became clear:
First, there is no consensus (yet) in the lang team about the await syntax. There are clearly a lot of possibilities and strong arguments in favor of all of them. We spent a long time exploring alternatives and produced quite a lot of interesting back-and-forth. An immediate next step for this discussion, I think, is to convert those notes (along with other comments from this thread) into a kind of summary comment that lays out the case for each variant, and then to continue from there. I'm working with @withoutboats and @cramertj on that.
Stepping back from the syntax question, another thing that we plan to do is an overall triage of the status of the implementation. There are a number of current limitations (e.g., the implementation requires TLS under the hood presently to thread information about the waker). These may or may not be blockers to stabilization, but regardless they are issues that do need to ultimately be addressed, and that is going to require some concerted effort (in part from the compiler team). Another next step then is to conduct this triage and generate a report. I expect us to conduct this triage next week, and we'll have an update then.
In the meantime, I am going to go ahead and lock this thread until we've had a chance to produce the above reports. I feel like the thread has already served its purpose of exploring the possible design space in some depth and further comments aren't going to be particularly helpful as this stage. Once we have the aforementioned reports in hand, we will also lay out the next steps towards reaching a final decision.
(To expand a bit on the final paragraph, I am pretty interested in exploring alternative ways to explore the design space beyond long discussion threads. This is a much bigger topic than I can address in this comment, so I won't go into details, but suffice to say for now that I am quite interested in trying to find better ways to resolve this -- and future! -- syntax debates.)
Quite a while ago, Niko promised that we would write a summary of the discussion in the language team and the community about the final syntax for the await operator. Our apologies for the long wait. A write up of the status of the discussion is linked below. Before that, though, let me also give an update on where the discussion stands now and where we will go from here.
Brief summary of where async-await stands right now
First, we hope to stabilize async-await in the 1.37 release , which branches on July 4th, 2019. Since we do not want to stabilize the await! macro, we have to resolve the syntax question before then. Note that this stabilization doesn’t represent the end of the road — more the beginning. There remains feature work to be done (e.g., async fn in traits) and also impl work (continued optimization, bug-fixing, and the like). Still, stabilizing async/await will be a major milestone!
As far as the syntax goes, the plan for resolution is as follows:
We want to be forward compatible with obvious future extensions to the syntax: processing streams with for loops in particular (like JavaScript's for await loop). That's why I've been working on a series of posts about this issue (first post here and more coming in the future).
At the upcoming lang-team meeting on May 2, we plan to discuss the interaction with for loops and also to establish a plan for reaching a final decision on the syntax in time to stabilize async/await in 1.37. We'll post an update after the meeting to this internals thread.
As I said before, we plan to reach a final decision in the near future. We also feel the discussion has largely reached a stable state: expect the next few weeks to be the "final comment period" for this syntax discussion. After the meeting we'll hopefully have a more detailed timeline to share for how this decision will be made.
Async/await syntax is probably the most hotly anticipated feature Rust has gained since 1.0, and the syntax for await in particular has been one of the decisions on which we have received the most feedback. Thank you to everyone who has participated in these discussions over the last few months! This is a choice on which many people have strongly divergent feelings; we want to assure everyone that your feedback is being heard and the final decision will be reached after much thoughtful and careful deliberation.
Activity
mehcode commentedon Jan 15, 2019
I thought it might be useful to write up how other languages handle an await construct.
Kotlin
C#
F#
Scala
Python
JavaScript
C++ (Coroutines TR)
Hack
Dart
With all that, let's remember that Rust expressions can result in several chained methods. Most languages tend to not do that.
lnicola commentedon Jan 15, 2019
I'd say that languages that support extension methods tend to have them. These would include Rust, Kotlin, C# (e.g. method-syntax LINQ and various builders) and F#, although the latter heavily uses the pipe operator for the same effect.
mehcode commentedon Jan 15, 2019
Purely anecdotal on my part but I regularly run in to dozen+ method chained expressions in Rust code in the wild and it reads and runs fine. I haven't experienced this elsewhere.
earthengine commentedon Jan 15, 2019
I would like to see that this issue was refered in the top post of #50547 (beside the check box "Final syntax for await.").
kvinwang commentedon Jan 16, 2019
Kotlin's syntax is:
The
awaitis just asuspendable function, not a first-class thing.mehcode commentedon Jan 16, 2019
Thank you for mentioning that. Kotlin feels more implicit because futures are eager by default. It's still however a common pattern in a deferred block to use that method to wait on other deferred blocks. I've certainly done it several times.
scottmcm commentedon Jan 16, 2019
@cramertj Since there are 276 comments in #50547, could you summarize the arguments made there to make it easier to not repeat them here? (Maybe add them to the OP here?)
chpio commentedon Jan 16, 2019
maybe you should add both use cases with a bit of context/description.
Also what's with other langs using implicit awaits, like go-lang?
197g commentedon Jan 16, 2019
One reason to be in favour of a post-fix syntax is that from the callers perspective, an await behaves a lot like a function call: You relinquish flow control and when you get it back a result is waiting on your stack. In any case, I'd prefer a syntax that embraces the function-like behaviour by containing function-paranthesis. And there are good reasons to want to split construction of coroutines from their first execution so that this behaviour is consistent between sync and async blocks.
But while the implicit coroutine style has been debated, and I'm on the side of explicitness, could calling a coroutine not be explicit enough? This probably works best when the coroutine is not directly used where constructed (or could work with streams). In essence, in contrast to a normal call we expect a coroutine to take longer than necessary in a more relaxed evaluation order. And
.await!()is more or less an attempt to differentiate betwen normal calls and coroutine calls.So, after hopefully having provided a somewhat new take on why post-fix could be preferred, a humble proposal for syntax:
future(?)future(await)which comes with its own tradeoffs of course but seems to be accepted as less confusing, see bottom of post.Adapting a fairly popular example from other thread (assuming the
logger.logto also be a coroutine, to show what immediately calling looks like):And with the alternative:
To avoid unreadable code and to help parsing, only allow spaces after the question mark, not between it and the open paran. So
future(? )is good whilefuture( ?)would not be. This issues does not arise in the case offuture(await)where all current token can be used as previously.The interaction with other post-fix operators (such as the current
?-try) is also just like in function calls:Or
A few reasons to like this:
.await!()it does not allude to a member that could have other uses.?. This keeps the number of precendence classes lower and helps with learning. And function calls have always been somewhat special in the language (even though the have a trait), so that there is no expectation of user code being able to define their ownmy_await!()that has very similar syntax and effect.FnOncewhileStreamswould behave like aFnMut. Additional arguments may also be accomodated easily.Futuresbefore, this captures how a?withPollshould have worked all along (unfortunate stabilization sequence here). As a learning step, it is also consistent with expecting a?based operator to divert control flow.(await)on the other hand would not satisfy this but afterall the function will always expect to resume at the divergent point.And reasons not to like this:
?appears to be an argument but it is not even applied to an expression. I believe this could be solved through teaching, as the token it appears to be applied to is the function call itself, which is the somewhat correct notion. This also positively means that the syntax is unambiguous, I hope.?can difficult to parse. Especially when you have one future returning a result of another future:construct_future()(?)?(?)?. But you could make the same argument for being able to a result of anfnobject, leading to expression such as this being allowed:foobar()?()?()?. Since nevertheless I've never seen this used nor complaint, splitting into separate statements in such cases seems to be required rarely enough. This issues also does not exist forconstruct_future()(await)?(await)?-future(?)is my best shot at a a terse and still somewhat concise syntax. Yet, its reasoning is grounded on implementation details in coroutines (temporarily returning and dispatching on resume), which might make it unsuitable for an abstraction.future(await)would be an alternative that could still be explainable afterawaithas been internalized as a keyword but the argument position is a bit hard to swallow for me. It could be fine, and it is certainly more readable when the coroutine returns a result.Pauan commentedon Jan 17, 2019
There's nothing special about
Result: Futures can return any Rust type. It just so happens that some Futures returnResultSo how would that work for Futures which don't return
Result?197g commentedon Jan 17, 2019
It seems it was not clear what I meant.
future(?)is what was previously discussed asfuture.await!()or similar. Branching on a future that returns a result as well would befuture(?)?(two different ways how we can relinquish control flow early). This makes future-polling(?)and result testing?orthogonal. Edit: added an extra example for this.Pauan commentedon Jan 17, 2019
Thanks for clarifying. In that case I'm definitely not a fan of it.
That means that calling a function which returns a
Future<Output = Result<_, _>>would be written likefoo()(?)?It's very syntax-heavy, and it uses
?for two completely different purposes.490 remaining items
ben0x539 commentedon Feb 14, 2019
We could introduce a trigraph like
...for users on keyboard layouts where~is inconvenient.norcalli commentedon Feb 14, 2019
At first, I was strongly on the side of having a delimiter-required prefix syntax as
await(future)orawait{future}since it is so unambiguous and easy to visually parse. However, I understand the proposals by others that a Rust Future is not like most other Futures from other languages, since it does not put a task onto an executor immediately, but instead is more of a control flow structure which transforms the context into what is homomorphic to a monad call chain essentially.It makes me think that it is somewhat unfortunate that now there is a confusion in attempting to compare it to other languages with that regard. The closest analog really is the monad
donotation in Haskell or theforcomprehension in Scala (which are the only ones I'm familiar with off the top of my head). Suddenly, I appreciate the consideration of proposing a unique syntax, but I'm afraid that the existence of the?operator has both encouraged and discouraged the use of other sigils with it. Any other sigil based operators next to?make it look noisy and confusing, such asfuture@?, but the precedent set by having a postfix sigil operator means that another one is not so ridiculous.I have, therefore, been convinced of the merit of the postfix sigil operator. The downside of this, is that the sigil I would've most preferred is taken by the never type. I would've preferred
!since I think thatfuture!?would make me chuckle whenever I wrote it, and it makes the most visual sense to me to see. I suppose$would be next, then since it is visually discernablefuture$?. Seeing~still reminds me of the early days of Rust when~was the prefix operator for heap allocation. It's all very personal, though, so I don't envy the final decision makers. Were I them, I would probably just go with the inoffensive choice of the prefix operator with required delimiters.lnicola commentedon Feb 14, 2019
I tend to disagree. The behaviour you mention is not a property of
await, but of the surroundingasyncfunction or scope. It's notawaitthat delays the execution of the code preceding it, but the scope that contains said code.I60R commentedon Feb 15, 2019
Probably the problem with weirdly looking
@symbol is that using it in that context was never been expected before, therefore in most fonts it's provided in so uncomfortable for us shape.Then providing a better glyph and some ligatures for popular programming fonts (or at least for Mozilla's
Fira Code) might improve situation a bit.In all other cases, for me it don't looks that
@is so weird to cause any real problems when writing or maintaining code.E.g. the following code uses different than
@symbol -@:Expand for comparison how it looks with regular ANSI `@`
Pzixel commentedon Feb 15, 2019
@norcalli
Then you probably want unambiguous
if { cond },while { cond }andmatch { expr }...It's not true. It's actually is like most other futures from other languages. Difference between "run until first await when spawned" vs "run until first await when polled" is not that big. I know because I worked with both. If you actually think "when this difference comes to play" you will find only corner case. e.g. you will get error when creating future on first poll instead of when it's created.
They could be internally different, but they are quite the same from user perspective so it doesn't make sense to me to make a distinction here.
CAD97 commentedon Feb 15, 2019
@Pzixel
That's not the difference we're talking about, though. We're not talking about lazy vs eager -to-first-await.
What we're talking about is that
awaitjoins the awaitedPromise(JS) /Task(C#) on the executor in other languages, which was already put on the executor at construction (so was already running in the "background"), but in Rust,Futures are inert state machines untilawait!-driven.Promise/Taskis a handle to a running asynchronous operation.Futureis a deferred asynchronous computation. People, including notable names in Rust, have made this mistake before, and examples have been linked before in the middle of these 500+ comments.Personally, I think this mismatch of semantics is large enough to counteract the familiarity of
await. OurFutures accomplish the same goal asPromise/Task, but though a different mechanism.Anecdotally, for me when I first learned
async/awaitin JavaScript,asyncwas "just" something I wrote to get theawaitsuperpower. And the way I was taught to get parallelism wasa = fa(); b = fb(); /* later */ await [a, b];(or whatever it is, it's been an age since I've had to write JS). My posit is that other people's view ofasynclines up with me, in that Rust's semantics don't mismatch onasync(give youawaitsuperpower), but onFutureconstruction andawait!.At this point, I believe the discussion on the differences in Rust's
async/Future/awaitsemantics has run its course, and no new information is being presented. Unless you have a new position and/or insight to bring, it'd probably be best for the thread if we leave that discussion here. (I'd be happy to take it to Internals and/or Discord.)Pzixel commentedon Feb 15, 2019
@CAD97 yes, I see your position, but I think the discinction is not that big.
You got me, I got you. So let the discussion have its flow.
orthoxerox commentedon Feb 15, 2019
@CAD97
If even people intimately familiar with Rust make that mistake, is it really a mistake?
nikomatsakis commentedon Feb 15, 2019
So, we had a number of discussions about async-await at the Rust All Hands. In the course of those discussions, a few things became clear:
First, there is no consensus (yet) in the lang team about the await syntax. There are clearly a lot of possibilities and strong arguments in favor of all of them. We spent a long time exploring alternatives and produced quite a lot of interesting back-and-forth. An immediate next step for this discussion, I think, is to convert those notes (along with other comments from this thread) into a kind of summary comment that lays out the case for each variant, and then to continue from there. I'm working with @withoutboats and @cramertj on that.
Stepping back from the syntax question, another thing that we plan to do is an overall triage of the status of the implementation. There are a number of current limitations (e.g., the implementation requires TLS under the hood presently to thread information about the waker). These may or may not be blockers to stabilization, but regardless they are issues that do need to ultimately be addressed, and that is going to require some concerted effort (in part from the compiler team). Another next step then is to conduct this triage and generate a report. I expect us to conduct this triage next week, and we'll have an update then.
In the meantime, I am going to go ahead and lock this thread until we've had a chance to produce the above reports. I feel like the thread has already served its purpose of exploring the possible design space in some depth and further comments aren't going to be particularly helpful as this stage. Once we have the aforementioned reports in hand, we will also lay out the next steps towards reaching a final decision.
(To expand a bit on the final paragraph, I am pretty interested in exploring alternative ways to explore the design space beyond long discussion threads. This is a much bigger topic than I can address in this comment, so I won't go into details, but suffice to say for now that I am quite interested in trying to find better ways to resolve this -- and future! -- syntax debates.)
nikomatsakis commentedon Mar 1, 2019
Async-await status report:
http://smallcultfollowing.com/babysteps/blog/2019/03/01/async-await-status-report/
Relative to my previous comment, this contains the results of the triage and some thoughts about syntax (but not yet a full syntax write-up).
nikomatsakis commentedon Mar 5, 2019
Marking this issue as blocking for async-await stabilization, at least for the time being.
withoutboats commentedon Apr 29, 2019
Quite a while ago, Niko promised that we would write a summary of the discussion in the language team and the community about the final syntax for the await operator. Our apologies for the long wait. A write up of the status of the discussion is linked below. Before that, though, let me also give an update on where the discussion stands now and where we will go from here.
Brief summary of where async-await stands right now
First, we hope to stabilize async-await in the 1.37 release , which branches on July 4th, 2019. Since we do not want to stabilize the
await!macro, we have to resolve the syntax question before then. Note that this stabilization doesn’t represent the end of the road — more the beginning. There remains feature work to be done (e.g., async fn in traits) and also impl work (continued optimization, bug-fixing, and the like). Still, stabilizing async/await will be a major milestone!As far as the syntax goes, the plan for resolution is as follows:
forloops in particular (like JavaScript'sfor awaitloop). That's why I've been working on a series of posts about this issue (first post here and more coming in the future).The writeup
The writeup is a dropbox paper document, available here. As you'll see, it is fairly long and lays out a lot of the arguments back-and-forth. We would appreciate feedback on it; rather than re-opening this issue (which already has more than 500 comments) I've created an internals thread for that purpose.
As I said before, we plan to reach a final decision in the near future. We also feel the discussion has largely reached a stable state: expect the next few weeks to be the "final comment period" for this syntax discussion. After the meeting we'll hopefully have a more detailed timeline to share for how this decision will be made.
Async/await syntax is probably the most hotly anticipated feature Rust has gained since 1.0, and the syntax for await in particular has been one of the decisions on which we have received the most feedback. Thank you to everyone who has participated in these discussions over the last few months! This is a choice on which many people have strongly divergent feelings; we want to assure everyone that your feedback is being heard and the final decision will be reached after much thoughtful and careful deliberation.