Use case
Current coroutine scope APIs like CoroutineScope.launch
are receiver-based.
It's pervasive, just like function coloring.
According to it's semantic, a CoroutineScope
is more fit as a context element if we have context parameter.
In Kotlin, a function can have at most two receiver for now, and this new API will make the receiver more free.
The Shape of the API
Example:
context(scope: CoroutineScope)
public fun launch(context(CoroutineScope) suspend () -> Unit): Job {
// ...
}