The title states my question.
What is exactly the reason why CoroutineScope.launch and Coroutine.async are just extension functions of CoroutineScope instead oa a member function?
What benefits does it provide?
I am asking because maybe the reason behind this design could be helpful in designing things in the future too.
Thank in advance.
launchandasyncare coroutine builders, but they aren't the only ones: look in integration modules forfuture(and anotherfuture),publish, the RxJava 2 builders etc. Obviously those can't be members ofCoroutineScope, so why shouldlaunchandasyncbe?In addition, by being extension functions you know they don't rely on any
CoroutineScopeprivates (well, they could rely oninternals since they are in the same module).