News for hackers. Stuff that matters.
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @02:06PM (#14763646)
Go's errors are really nice (if a bit repetitive) in my opinion. Type signatures enforce that you accept and acknowledge an error returned from an invocation, but leave it up to you to handle, pass along, or silently swallow.
Re:Toward Go 2 by hdhzy on Thursday July 13, 2017 @03:32PM (#14764417)
So... Just like checked exceptions in Java?
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @04:40PM (#14764990)
Yes, it's somewhat similar in that the compiler checks if you have handled or chosen not to handle an error. You're not allowed to ignore it (through omission).
Re:Toward Go 2 by baq on Thursday July 13, 2017 @05:24PM (#14765382)
yeah but better because you don't break the world if you add a new exception to a public method.
Re:Toward Go 2 by concede_pluto on Thursday July 13, 2017 @11:47PM (#14767311)
Declaring that every method throws Exception doesn't break the world any more than every Go function returning an argument of type error. You're intentionally saying pretty much anything could go wrong and nobody can plan ways to recover.
Re:Toward Go 2 by acdha on Thursday July 13, 2017 @03:05PM (#14764185)
Does that mean it now throws an error if you use the common punt like `foo, _ := …` and never check `_`?
Re:Toward Go 2 by growse on Thursday July 13, 2017 @04:38PM (#14764968)
No, because using `foo, _` you're explicitly saying that you don't care about the error.
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @04:37PM (#14764957)
No, but that's what I mean as intentionally ignoring.