dave08
03/12/2023, 3:42 PMcontext(Raise<...>)
requires suspend fun
since all side-effects should be suspend fun
... am I wrong?dave08
03/12/2023, 4:02 PMCLOVIS
03/12/2023, 4:04 PMCLOVIS
03/12/2023, 4:25 PMsuspend
anymoredave08
03/12/2023, 4:28 PMCLOVIS
03/12/2023, 4:29 PMYoussef Shoaib [MOD]
03/12/2023, 5:14 PMsimon.vergauwen
03/12/2023, 5:48 PMRaise
itself can be considered pure in the type-system. Similar to how Either
is pure, or rather referentially transparent.
We've experimented with a lot of different designs, and this is the only one that makes sense in Kotlin. TL;DR without exception you cannot interop with Kotlin Coroutines, and enforcing suspend
poses a lot of limitations in the API without any real benefits. AFAIK one of the reasons why Kotlin Coroutines choose CancellationException
was to not break try/finally
. Scala is also adding a similar construct into the language as Raise
with the similar semantics, rationale and implementation called Label
.