Youssef Shoaib [MOD]
07/05/2024, 5:08 AMsuspend fun foo() {
val b = bar()
TODO("Do other things")
}
suspend fun bar() {
delay(1)
suspendCoroutineUninterceptedOrReturn {
// I wish that it here would be foo's continuation, not bar's
}
}
I know that it's likely implementing this way for stack trace reasons, but assuming I don't care for stack traces, is there a magic compiler option or something to enable that? This would also allow automatic TCO for suspend functions that don't even have tailrec
on them.
Or is this feature useless in Kotlin? I'm reading up on literature from Scheme and other functional language where tail calls are very very important to have optimized well, but perhaps Kotlin code likely won't benefit from that? All thoughts appreciated!ephemient
07/05/2024, 6:09 AMYoussef Shoaib [MOD]
07/05/2024, 1:39 PMstartCoroutine
because I was observing different behaviour. I shall investigate further!