3 ms·
What is it about panic/recover that forking the language, not merely using Go in a non-idiomatic way, would be necessary? I could see forking it to add generic
by jlgreco 14y ago
What is it about panic/recover that forking the language, not merely using Go in a non-idiomatic way, would be necessary?
I could see forking it to add generics in a way that the official guys aren't satisfied with, but why is that needed to use another style of error handling?
- TazeTSchnitzel 14y agoBecause all of the rest of the ecosystem uses a different way, and switching between two different styles isn't fun.
- jlgreco 14y agoWhat would forking the language do to solve that? What changes would you actually make? Would it just be a matter of giving it a new name so that people didn't expect idiomatic Go things to work with it? Are we talking about just forking its standard library and not actually changing the language?
- luriel 14y agoAnyone using panic/recover across API boundaries to emulate exceptions should have their brains gofmt-d. But so far I have not noticed anyone doing this, perhaps because actually returning and handling errors properly is not as much of an issue as most people make it to be.
- jlgreco 14y agoI personally like Go's error handling so I wouldn't consider doing it, but what exactly would be the issue with doing so? The reasons not to that I have seen are all basically boil down to "Because you're not supposed to, it's not what it's for". Because of how recover works it certainly wouldn't make sense to use it exactly the same as try/catch is generally used, but what exactly would be the problem with using panic/recover for more common cases (less 'exceptional' cases...) if we've already decided to not value writing idiomatic code? It strikes me as a terrible idea, but try/catch does too.. I guess I don't understand why it would be even worse than that.
- luriel 14y agoBecause one of the nice things about Go is that I don't have to worry about this. Is not just unidiomatic code in itself, but it creates unidiomatic APIs that behave in ways Go programmers don't usually have to worry about. Unlike Python programmers, who should always be worrying about what exceptions any function or method they call could throw, hell, even setting a property or adding an item to a map or list can throw all kinds of exceptions. And this is rarely documented, and when it is documented it is usually incomplete, because whoever wrote that code doesn't know what exceptions might be thrown by any other code he calls.
- jlgreco 14y agoWell right, I get all of that. Just to be clear though, there is no point "adding" exceptions to Go because the functionality is already there, just named something else and meant to be used in a completely different way?