Stream: t-compiler

Topic: async vs generator stabilization


Jake Goulding (Sep 14 2018 at 19:24, on Zulip):

Last I heard, async/await is built on top of generators. When async/await stabilizes, will generators also stabilize?

rkruppe (Sep 14 2018 at 19:25, on Zulip):

there is no need to do that and many reasons not to, they're two rather different features after all

Jake Goulding (Sep 14 2018 at 19:28, on Zulip):

Sure, but people also want generators

Jake Goulding (Sep 14 2018 at 19:29, on Zulip):

many reasons not to

May I find a list of those somewhere?

Jake Goulding (Sep 14 2018 at 19:29, on Zulip):

probably in the tracking issue...

rkruppe (Sep 14 2018 at 19:29, on Zulip):

Sure, but people also want generators

yeah but i don't see what that has to do with tying the stabilization of generators to the stabilization of async/await

rkruppe (Sep 14 2018 at 19:31, on Zulip):

i'm sure you can find a bunch of unresolved questions in the tracking issue but the underlying reason is, it's a big and complicated feature and the only merged RFC for it was an experimental one

Jake Goulding (Sep 14 2018 at 19:31, on Zulip):

One possible reason that it would require it is if async/await were merely desugared to generators. I believe that to be the case at some point in the past.

rkruppe (Sep 14 2018 at 19:32, on Zulip):

no, stable surface syntax can desugar to unstable things. e.g. the desugaring for ? uses (or for the longest time used) an unstable trait

Jake Goulding (Sep 14 2018 at 19:32, on Zulip):

I'm also assuming that if async await is battle-hardened enough to stabilize, then transitively so must generators

nikomatsakis (Sep 14 2018 at 19:32, on Zulip):

the difference is

nikomatsakis (Sep 14 2018 at 19:32, on Zulip):

we are not wanting to stabilize the traits that generators implement

nikomatsakis (Sep 14 2018 at 19:33, on Zulip):

and various other details

nikomatsakis (Sep 14 2018 at 19:33, on Zulip):

which are not "exposed" by the async/await pattern

nikomatsakis (Sep 14 2018 at 19:33, on Zulip):

not to say it wouldn't be nice!

nikomatsakis (Sep 14 2018 at 19:33, on Zulip):

I'd love to be able to write iterators in line

nikomatsakis (Sep 14 2018 at 19:33, on Zulip):

I wonder if you can abuse async await to do that... :P

Jake Goulding (Sep 14 2018 at 19:35, on Zulip):

Is it valid to say that async/await uses a subset of (possible?) generator functionality?

Jake Goulding (Sep 14 2018 at 19:35, on Zulip):

e.g., as @rkruppe says

it's a big and complicated feature

nikomatsakis (Sep 14 2018 at 19:36, on Zulip):

Is it valid to say that async/await uses a subset of (possible?) generator functionality?

that is true

nikomatsakis (Sep 14 2018 at 19:36, on Zulip):

e.g., you can only yield () values :)

nikomatsakis (Sep 14 2018 at 19:36, on Zulip):

not that this is a point of contention

Jake Goulding (Sep 14 2018 at 19:38, on Zulip):

e.g., you can only yield () values :)

huh. I would have naïvely expected that the Future's / Stream's Item would have been yielded. I guess instead it's just yielding to go to the next step in the state machine (starting to talk out of my depth here)

nikomatsakis (Sep 14 2018 at 19:39, on Zulip):

No, the yields occur when an await cannot complete immediately

nikomatsakis (Sep 14 2018 at 19:39, on Zulip):

the Item is "returned", I believe

Jake Goulding (Sep 14 2018 at 19:40, on Zulip):

(This is where I wish that RFCs / the reference was updated with post-implementation changes, so I could go spelunking without looking into source code)

Jake Goulding (Sep 14 2018 at 19:42, on Zulip):

On a scale of "no big" to "woah", any gut feelings on how much code is needed to go from what async/await uses now(-ish) to completing a hypothetical generators RFC?

rkruppe (Sep 14 2018 at 19:43, on Zulip):

probably very little code but triple digit number of comments of bikeshedding

Jake Goulding (Sep 14 2018 at 19:44, on Zulip):

My first version of that comment was "what it would take to go from" and I realized that would include such discussions, so I tried to focus on what I was more interested in :wink:

Last update: Nov 20 2019 at 01:10UTC