why does the kotlin result class use Throwable for...
# stdlib
c
why does the kotlin result class use Throwable for failure instead of making it generic?
r
I'm not sure. Many people — including myself — prefer to use: https://github.com/michaelbull/kotlin-result
1
c
oh interesting, we have some code that uses result4k, maybe I'll try to convert it to kotlin-result as a spike.
a
Hi @christophsturm --- interesting i'm also building something similar, based on ideas from golang - andriesfc/result-for-kotlin: Domain Driven Error/Result handling for Kotlin 1.5 (github.com)
m
What do you mean by
making it generic
? I think parts of the design of Result is to use value classes for performance so it will not allocate (or allocate less?). Don't quote me on this though and read https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/result.md#binary-contract-and-implementation-details for the full details.
c
i meant make the error also a generic instead of a throwable. thanks for the link to the KEEP, it mentions that result has a very narrow focus, so i will probably just use one of the other result types
m
c
it mentions "It leads to abuse in cases where a user-provided API-specific sealed class would work better.", so they seem to favor api specific sealed classes to generic result types?
m
Looks like it!