by merb · 3y ago · 0 comments
My point is more against the notion that AI assistants would make careful language design any less important than in favor of any particular language. The popular programming languages all have their own virtues and drawbacks (and the unpopular ones almost certainly have at least their own drawbacks).
Go does not have error handling at all, just general value handing. What do you find awkward about its value handlers? They are essentially the same as every other C-style language out there.
How? What exactly makes this "too easy"?
In regards to a functions error returns, there are exactly two things a caller can do
func foo() (int, error) {
// foo code
}
// explicitely ignore the error
foo()
val, _ := foo()
// handling the error
val, err := foo()
_, err := foo()
If I do the latter, I cannot ignore `err`. If I do, the compiler yells at me because there is now an unused value in my code.If I do the former, then I made the conscious choice that the error doesn't matter to me. Yes, this goes for `foo()` as well, because Go makes it exceedingly clear that errors are just return values, and that call ignores all returns.
I never understood this. I do understand it is easy to forget to handle an error like it is easy to forget to handle a distance or temperature. Humans will make mistakes.
But nobody laments about how they forget to handle distances or temperatures, or cry for special constructs to ensure that they don't screw up their distance and temperature handling. What is it about the word error that sends developers into a tizzy?
Why would we want a solution that only works for errors and not for values of all kinds?