Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My whole point is that following the convention basically guarantees shadowing in many contexts. That's bad.


Sure, and every `x, err := f()` shadows any previous `err`. This kind of shadowing is totally normal and idiomatic, in no way bad.


err has the same problem as ok, it's true. It's a messy, kind of embarrassing spot in the language and idioms, not something to celebrate.


I'm not sure how useful it is to adjudicate what is ultimately just a property of the language. It's not something to celebrate, or mourn, or (importantly) try to work around, it's just the way things work.

It seems like you're just fighting the language. This is not the path to success :)


Do you also do err, err2, someOtherErr? Shadowing is the exact same situation. Errors are just values


Yes, it is the same situation. No, we don't tend to use unique names for errors. The idiom is just too strong.

This is somewhat mitigated by consistent consecutive error handling, meaning you always immediately dispatch an error on the line after assigning it. Every time we have had bugs because of this, it's because someone tried to be clever and delay handling an error until slightly later (like at the end of an if else chain where each branch might have had an error).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: