Kotlinx.coroutines: Proposal: deprecate "coroutineScope" function and rename it to "runScoped" instead.

Created on 16 Apr 2019  路  5Comments  路  Source: Kotlin/kotlinx.coroutines

Hi,
I propose renaming of coroutineScope function to runScoped.

  • Currently there is some confusion between runBlocking and coroutineScope and by observation seems many people thinks that coroutineScope is like launch (not blocks / suspends), maybe by renaming function to runScoped would help to associate it with runBlocking and helps to know(feel) that this call is also blocking / suspending.
  • Current name coroutineScope is a noun and feels like it would create a block of scope and returns it, but actually it runs a given block and returns block's result value, runScoped will reveal intention more clearly.
  • And there are too many "coroutinescope" definitions now, fun CoroutineScope(), interface CoroutineScope.

Most helpful comment

Any use of the word "blocking" is completely out of the question. To avoid confusion we explicitly reserve the word blocking for cases when the thread is block and use the term "suspension" to refer to case when coroutines wait for anything without blocking a thread.

All 5 comments

I completely agree this function is the main source of confusion in coroutines channel of Kotlin slack the last few months.

Some time ago I proposed another name awaitScope, but probably runScope is better name 馃憤

I do agree with the confusion that It makes. Although something other than run might be better.

Maybe joinScope is a good name?

I agree with this confusion name and prefer a name like runBlockingScope, this kind of name can emphasize this call will block the coroutine like the runBlocking block the current thread.

Any use of the word "blocking" is completely out of the question. To avoid confusion we explicitly reserve the word blocking for cases when the thread is block and use the term "suspension" to refer to case when coroutines wait for anything without blocking a thread.

Was this page helpful?
0 / 5 - 0 ratings