10/13/2020, 4:07 PM
I recall a discussion in the past about using function expression (
) with
. In general I favor avoiding this and other people also found it confusing. Do you know if there is any kind of official guideline about it?
as @raulraja I expect expression functions to not have side effects

Fabian Braun

10/13/2020, 4:25 PM
kotlinx.coroutines docs propose this for writing tests:
fun exampleTest() = runBlockingTest {
    // ...
But that’s a special case I guess…
👍 1


10/13/2020, 9:24 PM
In Kotlin expressions can have side effects and the only way to track them is using suspend. Suspend guarantees exceptions are handled but just an expression vs a block with a return it seems more of syntactic preference since Kotlin does not enforce it. In suspend you are forced to deal with it
In languages like Scala is recommended but I don't know what makes most sense for Kotlin. Kotlin suspend is also opt in for effect tracking, you can still do I/O and effects without suspend.