I want to propose my own counter-proposal to the discussion that’s ongoing with Go and error handling.

Here it is: https://docs.mills.io/ix4qDHMnQUSPxZ5tXz12Vg?view

It’s very rough and needs much more work, but essentially I want to propose the following change to the language’s grammar:

f := os.Open("foo.txt") or (e error) {
    log.Fatal("error opening file; %s", e)
}

⤋ Read More

hmm this would convert down to:

var f os.File
if f, e = os.Open("foo.txt"); e != nil {
    log.Fatal("error opening file; %s", e)
}

im not sure if its much better.

⤋ Read More

@xuu@txt.sour.is I’m not necessarily saying it is to be bluntly honest. But it’s far better than this ? garbage. I don’t want to be rude, but honestly wtf is wrong with people and making languages harder to read?! 🤦‍♂️

⤋ Read More

@xuu@txt.sour.is And you’re right, it only really saves a single line. I think I’ve even commented on a similar discussion a few years ago as well where I showed concretely the abrustdity of the community wanting to change this. If I recall, the whole pattern of:

if err != nil {
    ...
}

basically accounts for <1-3% of your codebase in the first place.

The entire thing (fuss) is really just pathetic IMO.

⤋ Read More

If people just wrote error free code to begin with, there would be no need for error handling! :-P

No, honestly, I don’t think that there is anything wrong with the current approach. I don’t see any wins of any of the proposals I’ve come across.

⤋ Read More

Participate

Login or Register to join in on this yarn.