Re:Alan Donovan and Brian Kernighan Answer Questions on Go
by mahyarm on Friday November 20, 2015 @06:16PM
(#10604524)
I like how Swift does it. There are no real exceptions, but error object handling to jump to the end is fairly easy. It reduces boilerplate and increases readability.
do {
try error-return-statement
statement
statement
try error-return-statement
} catch ErrorType1 {
...
} catch ErrorType2 {
...
}
It looks like exceptions, but under the hood error objects are being returned by error-return-statements, thus the explicit try keywords before them. It retains go error object simplicity, but keeps things readable and tidy.
Re:Alan Donovan and Brian Kernighan Answer Questions on Go
by AnimalMuppet on Friday November 20, 2015 @07:15PM
(#10604776)
jerf, when you write that blog post, would you submit it on HN? I'd like to see it.
By that standard, exceptions actually fit in between C-style obliviousness and explicit error returns. They do allow a certain amount of implicitness (does this code have no try/catch exception handlers because the programmer is deliberately invoking the default exception behavior, or is it because they didn't think about errors at all?), but you still can't ignore errors the way you can in C. And then with explicit error returns, you can't ignore them at all without leaving a trail of your decision to do so right there in the source code.
Checked exceptions tried to straddle the boundary, but I think I have to agree with the general consensus that they are a failed experiment. One of my "cut through the noise" metrics for language design decisions is "do any subsequent languages pick up the feature?". If a language as dominant as Java has a feature, but after 10-15 years no new languages are picking up the feature, that Means Something.