4 ms·
rust-style "sum type" errors are values too
by evertedsphere 1y ago
rust-style "sum type" errors are values too
- 9rx 1y agoBut, of course, makes the incorrect assumption that <T, E> are dependent variables. The idiomatic Go approach is much more representative of reality. Tradeoffs, as always.
- masklinn 1y agoYou have things the wrong way around. A developer uses Result because T and E are exclusive. If they’re not, they will use something else. And it will be clear to the caller that they are in a rare oddball case. The idiomatic Go approach makes no provision for such distinctions at all.
- 9rx 1y ago> You have things the wrong way around. No. You have not considered what is going on around you. > A developer uses Result because T and E are exclusive. A programming language may be designed around that premise, but that is not the case in the real world (faults in the real world are never binary), and it is certainly not aligned with the design of Go. > The idiomatic Go approach makes no provision for such distinctions at all. Naturally. It logically can't because T and E are both considered to be always valid per the fundamentals of the language. The idioms emerged as an extension of those core principles. As before, other languages may take different view, but Go isn't those languages. That's what makes this changing error handling business so hard. If Go were a completely different language then it would be easy to adopt something like monads, but for the Go we have things like that just don't logically fit and it is not yet clear what does.