-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: Go 2: Error-Handling Paradigm with !err Grammar Sugar #64228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok I will say it, this doesn't look half bad in my eyes. I can see it in some cases while keeping the good old handle your errors in most cases. Still I think the only thing I really want for the future is method chaining for functions returning errors. |
if you wish to file proposals, please make the effort to fill out the questionnaire and properly explain the semantics. otherwise it's just unclear what we're looking at. |
I just occasionally take a look, and I'm not sure if I will use the Go language to develop websites in the future. I really don't care whether the official team adopts it or not, so it's not important to me. |
Hi @xiaokentrl, I've noticed this is your sixth error handling proposal you've submitted (#57944, #57957, #63621, #63647, #63961, #64228), with four of them in the past month alone, and none have received significant positive feedback from the community. It might be beneficial to discuss your ideas and share your drafts with others outside the issue tracker before finalizing and filing a proposal. |
The title !err even doesn't match the text using |
Based on this examples, the way I understand the proposal is as follows: @error{
srcFile, err := os.Open("test.txt")
defer srcFile.Close()
dstFile, err2 := os.Create("copy.txt")
defer dstFile.Close()
_, err3 = io.Copy(dstFile, srcFile)
}.catch(err || err2 || err3){
fmt.Println( err )
fmt.Println( err2 )
fmt.Println( err3 )
} Inside the braces of the In the Assuming I understood the above correctly, I think a challenge with this design is that it does not follow any of the existing rules for lexical scoping and symbol visibility in other language features in Go. For example, a subset of the declarations inside the This inconsistency with the rest of the language causes some follow-up questions to have unclear answers too. For example, consider the following: @error{
err := exampleFallible()
if anyPredicate {
// the following line is the main problem...
err := anotherExampleFallible()
}
}.catch(err) {
// ...
} I've annotated a line saying "the following line is the main problem". That line declares a new symbol Does that I have some other concerns too, but I picked this one as the most significant to raise. This sort of interaction with other parts of the language is why just an example without any explanation of how the spec would change to represent the new feature tends to be an insufficient language proposal, and I expect is part of why the engagement of this and your other similar proposals has been... challenging. |
This has nothing to do with me; I'm just putting forward an idea. |
Based on the comments and the voting, and the similarity to previous proposals without addressing their shortcomings, this is a likely decline. Leaving open for a further four weeks for final comment. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
No change in consensus, so declined. |
@apparentlymart
@thediveo
This has nothing to do with me; I'm just putting forward an idea.
Add
@error()
, and@error().catch{ }
The text was updated successfully, but these errors were encountered: