logoalt Hacker News

masklinnlast Thursday at 5:24 AM1 replyview on HN

You 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.


Replies

9rxlast Thursday at 2:05 PM

> 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.