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

zak.taccardi

03/09/2020, 5:57 PM
Can someone explain why
Result
was added to the standard lib, when it’s effectively useless outside of Coroutines? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/ A standard
Result<T>
type that we could use as a return value would be incredible useful, and this seems to be a waste of a namespace?
z

Zach Klippenstein (he/him) [MOD]

03/09/2020, 6:03 PM
Why is it useless outside of coroutines?
z

zak.taccardi

03/09/2020, 6:03 PM
I just really want to use it as a return type
maybe that just means I don’t fully understand it
z

Zach Klippenstein (he/him) [MOD]

03/09/2020, 6:07 PM
Oh, because of the error? The release notes for 1.3.70 said they lifted restrictions on it, I just assumed that’s what they meant. But yea it doesn’t look like they did.
Well, I could have sworn I saw that in the release notes somewhere… but now I can’t find it.
z

zak.taccardi

03/09/2020, 6:10 PM
oh wow this is a big deal. We’re an internal company SDK so I don’t think we should be using experimental APIs like
inline class
yet though
(btw, I ❤️ the experimental stuff Kotlin does. Allows for great feedback and iteration. I couldn’t imagine coroutines without
CoroutineScope
)
z

Zach Klippenstein (he/him) [MOD]

03/09/2020, 6:12 PM
And who knows when inline classes are going to stabilize. I don’t think I’ve seen anything about that for 1.4 😞
z

zak.taccardi

03/09/2020, 6:12 PM
inline classes can’t be consumed from Java right though? So using
Result<T>
on a public API that may be called from Java would be a problem?
z

Zach Klippenstein (he/him) [MOD]

03/09/2020, 6:14 PM
I think they can, but it boxes them so you don’t get the optimizations. I’m a bit rusty on the details there though.
👍 1
7 Views