https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

cedric

02/09/2017, 7:02 AM
Call it
blockBlock
, a verb and a noun. Problem solved.
🧌 4
v

voddan

02/09/2017, 9:28 AM
cedric: this whole thing with nouns-vs-verbs is not clear to me
I understand why JB wants functions to be nouns - because this is like commanding the compiler
run blocking!
But on the other hand if we have a
blocking { launch() }
scope function, it is like commanding
launch, but blocking
E.i. "blocking" is participle here, not a noun
Opinions?
k

kenkyee

02/09/2017, 11:35 AM
I'm actually wondering why we need runblocking... If it's running on the current thread, it's like it's inline code, isn't it? What's the difference between the code without that keyword?
c

cedric

02/09/2017, 3:03 PM
@voddan I agree. I think it's important to try and be consistent by default (e.g.
Optional
from Java makes more sense than
Option
of Scala) but you shouldn't try to take this too far. To me,
runBlocking
is perfectly acceptable.
v

voddan

02/09/2017, 3:07 PM
@cedric sooo, you don't see a big deal having
runBlocking
instead of
blocking
?
c

cedric

02/09/2017, 3:07 PM
Not really
v

voddan

02/09/2017, 3:09 PM
oh, ok. It is just that I was trying to express why I don't see a good enough reason to have an uglier
runBlocking
good to know that ether way the API is "good enough"
r

Ruckus

02/09/2017, 3:30 PM
@voddan I think they're equal.
blocking
looks prettier, but
runBlocking
is clearer. Both of those claims are opinions though, so getting everyone's opinion on the matter is valuable.
👍 1
It's a similar problem with
async
vs
defer
.
defer
is more accurate and clear, but
async
is more familiar.
k

kenkyee

02/09/2017, 11:51 PM
Ahhh...I see...Runblocking is just to make it explicit. One of the things that is not obvious with c# async await is that an async method is blocking into you hit the first await. This is the same thing...
2 Views