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

rrader

02/10/2017, 8:58 AM
Maybe
async
should return
Coroutine
class
e

elizarov

02/10/2017, 9:06 AM
rrader: This is the wrong concept. Coroutine is just a background computation. Coroutine ~ Thread. While
async
returns an object also known (in computer science) as a future or a promise: https://en.wikipedia.org/wiki/Futures_and_promises
We could have named
Coroutine
the result of
launch
function, but we don’t need any extra functions on it beyond those that are already provided by a
Job
.
r

rrader

02/10/2017, 9:15 AM
but
Deferred
also seems incorrect, because it means it will run later
I think it should meen that is a subroutine that runs at same time, maybe
AsyncSubroutine
h

hackerham

02/10/2017, 9:20 AM
Coroutine has different meaning already, it wont be good to use it two times
e

elizarov

02/10/2017, 9:21 AM
Deferred here is just a synonym for Promise/Future and it does mean that it is run later. That is actually what is happening — it is being run later
You can also say that it is run asynchronously, but nobody is calling the resulting value async-anything.
Look at the
async
result in other languages: C# calls it
Task
, JS calls it
Promise
, Dart calls it
Future
.
In CS, there is no accepted synonym for future/promise that uses “async” root
r

rrader

02/10/2017, 9:37 AM
ok, it will run almost at the same time in Go also are
defer
https://tour.golang.org/flowcontrol/12
it meen it will run at the end of a function
e

elizarov

02/10/2017, 10:42 AM
Go’s
defer
is a misnomer. We cannot help that.
7 Views