Stream: wg-async-foundations

Topic: Async fn desugaring discussion?

magnet (Apr 18 2019 at 13:18, on Zulip):

Hey, apologies if this makes no sense (I'm not a contributor to Rustc) or if this has been discussed to death before.

Are there still any talks about async fn desugaring? We have been using async/await for about 6 months and it's great, but when discussing it I keep meeting people who struggle using it in no_std/environments lacking TLS. It feels weird that a language construct requires finding the Context/Waker from somewhere (i.e, a global variable, even if it's in TLS) and looks somewhat "unrusty".
Is there any way async fns could be stabilized without getting into a place where global/TLS Context must be supported forever?

Random musings: currently, async fns are sugared/colored "enough" that no one directly calls them without a framework/mediator (e.g, the await! macro). I don't think it would be problematic to most users to desugar async fn foo(bar: Bar) {} to fn foo(ctx: &mut Context, bar: Bar) -> XXX {}, butawait would have to be parameterized implictly? and there are no implicit parameters in Rust (or something similar, yet)... Could that implicit parameter thing be behind another feature gate, just like generators are, and we'd have async and await stabilized without committing to TLS?

Taylor Cramer (Apr 18 2019 at 14:54, on Zulip):

@magnet TLS is not a fundamental requirement of the design. It's usage in async/await will be removed when generators can take arguments.

Taylor Cramer (Apr 18 2019 at 14:54, on Zulip):

(or when we make a special tailored hack for it)

magnet (Apr 18 2019 at 15:20, on Zulip):

@Taylor Cramer but how can you stabilize async fns without stabilizing the desugaring or the exact behavior of generators?

magnet (Apr 18 2019 at 15:22, on Zulip):

My understanding is that if async fn becomes stable and people start depending on how it is implemented, it will prevent alternative approaches to pass the context

magnet (Apr 18 2019 at 15:24, on Zulip):

(I do understand how generators with arguments can solve this, but wouldn't changing that after async stabilization be a problem?)

Taylor Cramer (Apr 18 2019 at 15:57, on Zulip):

@magnet no, the stabilization does not include any aspect of generators nor the desugaring

magnet (Apr 18 2019 at 18:11, on Zulip):

Alright, I see, thanks!

Last update: Jul 16 2020 at 14:55UTC