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

freddiewang

09/11/2018, 3:48 AM
does anyone know how
suspendCoroutineUninterceptedOrReturn
or
intercepted
is generated in coroutine library? I’m confused about why some core functions are auto-gen… Any specific reason?
e

elizarov

09/11/2018, 8:50 AM
What exactly you what to know? What do you mean by “autogenerated”?
f

freddiewang

09/12/2018, 7:30 AM
Hi @elizarov, because i am studying the implementation of kotlin coroutines and found some core functions like
suspendCoroutineUninterceptedOrReturn
throwing
NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic")
. I am just curious where is the “real” implementation of those intrinsic functions and why kotlin has such design. It is very interesting. I can’t find them directly in the code base
e

elizarov

09/12/2018, 7:32 AM
They are intrinsic, which means they are implemented by compiler. This particular function does not actually do anything. It is just a syntactic trick to expose coroutines calling convention. You can read more about it here: https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md#implementation-details
f

freddiewang

09/12/2018, 7:36 AM
thanks Roman, reading the document!
6 Views