Joost Klitsie
12/17/2020, 5:09 PMJavier
12/17/2020, 5:19 PMNir
12/17/2020, 5:22 PMNir
12/17/2020, 5:23 PMNir
12/17/2020, 5:25 PMMarc Knaup
12/17/2020, 5:35 PMException
or if I donât catch anything. But thereâs no unified solution yet.Nir
12/17/2020, 5:42 PMNir
12/17/2020, 5:44 PMinterface Outcome<T>
that erases the error type to simply something throwable, and then class Result<T, E> : Outcome<T>
or something like that, where E can just be a simple class that Result can wrap into a throwable, or something like that (might be tricky because of type erasure)Joost Klitsie
12/17/2020, 5:46 PMMarc Knaup
12/17/2020, 5:46 PMJavier
12/17/2020, 5:47 PMEither
could be added to the stdlibNir
12/17/2020, 5:48 PMNir
12/17/2020, 5:48 PMNir
12/17/2020, 5:48 PMNir
12/17/2020, 5:49 PMNir
12/17/2020, 5:49 PMMarc Knaup
12/17/2020, 5:50 PMMarc Knaup
12/17/2020, 5:50 PMMarc Knaup
12/17/2020, 5:51 PMAny
results because you end up accidentally creating nested Outcome<Outcome<âŠ>>
Marc Knaup
12/17/2020, 5:51 PMJavier
12/17/2020, 5:51 PMJoost Klitsie
12/17/2020, 5:52 PMMarc Knaup
12/17/2020, 5:52 PMJoost Klitsie
12/17/2020, 5:52 PMNir
12/17/2020, 5:52 PMMarc Knaup
12/17/2020, 5:53 PMJavier
12/17/2020, 5:53 PMfold
function?Marc Knaup
12/17/2020, 5:53 PMNir
12/17/2020, 5:54 PMfun foo(): Outcome<Int> {
val x = bar1().getOr { return it} + bar2().getOr { return it }
}
Nir
12/17/2020, 5:54 PMMarc Knaup
12/17/2020, 5:54 PMMarc Knaup
12/17/2020, 5:54 PMMarc Knaup
12/17/2020, 5:54 PMNir
12/17/2020, 5:54 PM?
in Rust.Marc Knaup
12/17/2020, 5:54 PMdoâŠcatch
Nir
12/17/2020, 5:54 PMNir
12/17/2020, 5:54 PMNir
12/17/2020, 5:54 PMNir
12/17/2020, 5:55 PMNir
12/17/2020, 5:56 PMMarc Knaup
12/17/2020, 5:56 PMsealed class
.
if you donât - Kotlin needs a solid concept for that.Nir
12/17/2020, 5:56 PMNir
12/17/2020, 5:56 PMMarc Knaup
12/17/2020, 5:56 PMNir
12/17/2020, 5:57 PMMarc Knaup
12/17/2020, 5:57 PMMarc Knaup
12/17/2020, 5:57 PMMarc Knaup
12/17/2020, 5:57 PMMarc Knaup
12/17/2020, 5:57 PMNir
12/17/2020, 5:57 PMNir
12/17/2020, 5:58 PMNir
12/17/2020, 5:58 PMMarc Knaup
12/17/2020, 5:58 PMNir
12/17/2020, 6:00 PMNir
12/17/2020, 6:00 PMNir
12/17/2020, 6:01 PMNir
12/17/2020, 6:01 PMMarc Knaup
12/17/2020, 6:01 PMNir
12/17/2020, 6:02 PMNir
12/17/2020, 6:02 PMNir
12/17/2020, 6:02 PMMarc Knaup
12/17/2020, 6:02 PMInt
in Java. So exceptions must be typed somehowNir
12/17/2020, 6:02 PMMarc Knaup
12/17/2020, 6:03 PMNir
12/17/2020, 6:03 PMNir
12/17/2020, 6:04 PMNir
12/17/2020, 6:04 PMMarc Knaup
12/17/2020, 6:05 PMNir
12/17/2020, 6:06 PMNir
12/17/2020, 6:06 PMMarc Knaup
12/17/2020, 6:06 PMOkay. At any rate, swiftâs approach is basically equivalent to returning Outcome<T>âs, but with syntactic sugar (which helps a lot)
T
in Swift. Just Outcome
.Marc Knaup
12/17/2020, 6:07 PMNir
12/17/2020, 6:08 PMfoo().getOr { return it}
is way worse than foo()?
. Maybe if they could adapt some of the null syntactic sugar for a built in Result type đ€·Marc Knaup
12/17/2020, 6:09 PMMarc Knaup
12/17/2020, 6:09 PMtry?
and try!
in Swift is okay though.Marc Knaup
12/17/2020, 6:09 PMNir
12/17/2020, 6:15 PMNir
12/17/2020, 6:16 PMgetOr { return it }
isn't that badMarc Knaup
12/17/2020, 6:16 PMifError { return it }
Nir
12/17/2020, 6:16 PMMarc Knaup
12/17/2020, 6:16 PMreturn
in various situationsNir
12/17/2020, 6:17 PMNir
12/17/2020, 6:17 PMNir
12/17/2020, 6:17 PMMarc Knaup
12/17/2020, 6:18 PMallan.conda
12/17/2020, 8:30 PMIf you have a hundreds of functions each calling several other functions, every single call result would have to be unwrapped, errors returned and values be used for the remainder of the function.@Marc Knaup Can you give an example about what you mean here? Just trying to understand how it went bad for you. Not asking for a hundred-function sample, just enough for us to understand that itâs not gonna scale very well.
Joost Klitsie
12/17/2020, 8:34 PMNir
12/17/2020, 8:51 PMNir
12/17/2020, 8:51 PMgetOr { return it }
Joost Klitsie
12/17/2020, 8:52 PMNir
12/17/2020, 8:52 PMfun foo() {
val result = bar(baz1().getOr { return it }, baz2().getOr { return it }).getOr { return it }
}
Nir
12/17/2020, 8:52 PMNir
12/17/2020, 8:53 PMfun foo() {
val result = bar(baz1(), baz2())
}
Nir
12/17/2020, 8:53 PMfun foo() {
val result = bar(baz1()?, baz2()?)?
}
which isn't that badallan.conda
12/18/2020, 3:04 AM