News for hackers. Stuff that matters.
Re:The power of Result types in Swift by mpweiher on Sunday June 17, 2018 @05:40PM (#17334482)
What I found interesting is that if you have a pipe/filter architectural style, your happy path stays completely free of error handling, because when a filter doesn't have a good result, it just doesn't pass any data to the next filter in line. Done!

You can then centralize the error handling by having a "stderr"-like output on your filters.

When you have a call/return architectural style, you need to return something, and thread the result along, making things more complicated.

Re:The power of Result types in Swift by singularity2001 on Monday June 18, 2018 @05:01AM (#17336774)
>> if you have pipes/filters, you stay free of error handling: when a filter doesn't have a result, it just doesn't pass any data to the next filter in line.

That is an important root insight. It also applies to for loops, and could apply to switch statements

switch result { case something: break case none: error: empty: default: //? }

Re:The power of Result types in Swift by lmm on Monday June 18, 2018 @08:16AM (#17337626)
I find this concept of a "stderr output" far more complicated. What's next, a "controlling terminal"?

Values are much easier to reason about and inspect than functions, so it's better to have simple functions that return complicated values than to complicate the functions themselves.

Re:The power of Result types in Swift by mpweiher on Monday June 18, 2018 @11:56AM (#17339211)
> I find this concept of a "stderr output" far more complicated.

And you know this how?

> Values are much easier to reason about and inspect than functions

Right, which is why we want to avoid functions as much as possible.

> simple functions that return complicated values than to complicate the functions themselves

Fortunately, these filters aren't functions, so this doesn't complicate them, it makes them simpler.

Re:The power of Result types in Swift by lmm on Monday June 18, 2018 @12:46PM (#17339657)
> And you know this how?

Professional experience.

> Fortunately, these filters aren't functions, so this doesn't complicate them, it makes them simpler.

Functions are at least restricted enough that you can sort of reason about them. If these things are not even functions then there's no hope of ever understanding them.