proposal: Go 2: Better way for error handling #64674
Labels
error-handling
Language & library change proposals that are about error handling.
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
Proposal Details
Would you consider yourself a novice, intermediate, or experienced Go programmer?
What other languages do you have experience with?
Would this change make Go easier or harder to learn, and why?
This change is intended to make Go easier to use, especially for those who are familiar with languages that provide more advanced error handling syntax. It can simplify error handling and make the code more concise.
Has this idea, or one like it, been proposed before?
No, this specific proposal has not been made before.
Who does this proposal help, and why?
This proposal benefits developers who are accustomed to more expressive error handling syntax in other languages. It aims to improve the readability and conciseness of error handling code.
What is the proposed change?
Introduce an advanced error handling syntax using the ?? operator, allowing for concise error handling in a single line or invoking custom error handling functions.
Please describe as precisely as possible the change to the language.
The proposed change introduces a new syntax ?? for handling errors in a more advanced and concise manner. It allows developers to handle errors directly inline or call custom error handling functions.
What would change in the language spec?
The language specification would need to be updated to include the new ?? operator and its behavior in the context of error handling.
Please also describe the change informally, as in a class teaching Go.
This change simplifies error handling by providing a concise syntax for handling errors inline or through custom error handling functions.
Is this change backward compatible?
Show example code before and after the change.
Before:
After:
What is the cost of this proposal?
How many tools would be affected?
What is the compile time cost?
What is the run time cost?
Can you describe a possible implementation?
An implementation would involve modifying the parser to recognize the new ?? syntax and updating the error handling logic accordingly.
How would the language spec change?
The language specification would need to include the definition and behavior of the ?? operator in the context of error handling.
Orthogonality: how does this change interact or overlap with existing features?
This change is orthogonal to existing features and does not overlap with them.
Is the goal of this change a performance improvement?
Does this affect error handling?
If so, how does this differ from previous error handling proposals?
This proposal focuses on enhancing the syntax for error handling, providing a more concise and expressive way to handle errors.
Is this about generics?
If so, how does this relate to the accepted design and other generics proposals?
N/A
The text was updated successfully, but these errors were encountered: