Closed mainjzb closed 1 month ago
Thanks, but this is not like anything else in Go. A change in Go for error handling has to do more than just reduce error boiling boilerplate: it has to fit into the rest of the language.
Based on the discussion above and the emoji voting, this is a likely decline. Leaving open for four weeks for final comments.
Go Programming Experience
4 years
Other Languages Experience
C, C++, Java, Dart, zig, rust
Related Idea
Has this idea, or one like it, been proposed before?
yes issues/21161
Does this affect error handling? yes
Is this about generics? no
Is this change backward compatible? compatible
Proposal
scr: https://github.com/mainjzb/goerr
Make
#
as error symbol, I believe people can learn and understand it quickly. (Maybe other symbol replace it)#@
as handler error symbol. Help people read code and simplify code.I have read go/issues/21161 My imaging is something similar to that.
before
now
igmore
6 char more than other 4 char#@wrap
equal to#@wrap("io.Wirite err:")
, omit parameter make it easier for people to handle error instead of ignore error.MustXxx()
andXxx()
two sets api. Now we just need only one. Just likego
keyword, we no longer need sync and async functions.People should reduce the discussion of compilation details. Focusing on achieving agreement on lang style.
Method chaining
move error to suffix have other benefit that separate return value and error. now we can Method chaining. Some people dislike Method Chaining but I like it.
Is this change backward compatible?
No
Orthogonality: How does this change interact or overlap with existing features?
This is an orthogonal new feature that can be used not only for error handling, but also to reduce repetitive boilerplate in other cases.
Would this change make Go easier or harder to learn, and why?
Most language errors are more complex. Only by making people aware that this is complex can they pay attention to it
Cost Description
No response
Changes to Go ToolChain
All of them.
Performance Costs
Compile time: extra injection work. Run time cost: none.
Prototype
No