You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Functions like eitherTry and Try would also be useful when catching exceptions thrown by suspending functions. The current implementations don't support this. For example, I cannot to this:
funmain(args:Array<String>) = runBlocking {
val a = async<String>(CommonPool) {
throwThrowable()
}
val result = eitherTry {
a.await()
}
println(result)
}
This fails to compile on a.await because we are not in a suspending block.
I see two potential solutions:
Add new functions (or change existing signatures) to support coroutines. E.g: eitherTry becomes suspend fun <T> eitherTry(body: suspend () -> T): Either<Throwable, T>
Simply mark these functions inline.
The text was updated successfully, but these errors were encountered:
I see you marked eitherTry as inline in 1.2, but the reality is almost every function that accepts a lambda callback should be marked inline so that it can be used from a coroutine when the callback might suspend.
Functions like
eitherTry
andTry
would also be useful when catching exceptions thrown by suspending functions. The current implementations don't support this. For example, I cannot to this:This fails to compile on
a.await
because we are not in a suspending block.I see two potential solutions:
eitherTry
becomessuspend fun <T> eitherTry(body: suspend () -> T): Either<Throwable, T>
inline
.The text was updated successfully, but these errors were encountered: