CoroutineContext
context parameter in suspend
functions
#452
Replies: 3 comments 8 replies
-
I like the proposal in general, thought I think that the main point (that suspend function modifier adds a coroutine context as a context parameter) should be written more explicitly. I've read KEEP several times and only then understood the point. |
Beta Was this translation helpful? Give feedback.
-
Looking at this example:
I'm not sure I'm following why in case of But in case of Even if such behavior more logical, I think it's less desired and just prohibit such shadowing maybe better solution |
Beta Was this translation helpful? Give feedback.
-
I think the proposal makes a lot of sense, but I'm concerned that the new context parameter could introduce some confusion because it looks very similar to (but behaves differently from) a coroutine scope.
In fact, I can see a world where we might want to replace coroutine scopes with context parameters—which would, I think, run into conflict with this proposal. If coroutine scopes and context parameters are just two different ways to bring coroutine context into scope, why do I say that the two things conflict? Because the proposed context parameter provides access to the current coroutine context, which is typically not what we want from a coroutine scope. Inside a suspending function, if we want a coroutine scope, we want it to use not the current context but a new child context, e.g. via the Here's my concern:
With all that said, I do think it would be great to have an easier way to call |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This thread is a discussion around a new proposal on bridging context parameters and
CoroutineContext
together.The proposal text
Beta Was this translation helpful? Give feedback.
All reactions