You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Has this idea, or one like it, been proposed before?
Does this affect error handling?
Is this about generics?
Is this change backward compatible? Breaking the Go 1 compatibility guarantee is a large cost and requires a large benefit
Has this idea, or one like it, been proposed before?
No, but not 100% sure
Does this affect error handling?
No.
Is this about generics?
No.
Proposal
This is a backward-compatible proposal to allow branching statement like if or switch to be used as an expression to be used for assignments.
This should reduce verbosity of code while keeping the impact minimal. It can also be used by static analysis tools to find unhandled scenarios with iota transformations.
Also, it would inadvertantly mean that go would have a ternary operator.
Consider the following code to find the maximum of two numbers:
Go Programming Experience
Novice
Other Languages Experience
Java, Python, Kotlin, JS
Related Idea
Has this idea, or one like it, been proposed before?
No, but not 100% sure
Does this affect error handling?
No.
Is this about generics?
No.
Proposal
This is a backward-compatible proposal to allow branching statement like if or switch to be used as an expression to be used for assignments.
This should reduce verbosity of code while keeping the impact minimal. It can also be used by static analysis tools to find unhandled scenarios with iota transformations.
Also, it would inadvertantly mean that go would have a ternary operator.
Consider the following code to find the maximum of two numbers:
with an if expression, it can be simplified to:
Some similar proposals would get an alternative syntax to be implemented:
Language Spec Changes
No response
Informal Change
No response
Is this change backward compatible?
Mostly. Haven't though about the whole picture
Orthogonality: How does this change interact or overlap with existing features?
No response
Would this change make Go easier or harder to learn, and why?
It would reduce the verbosity of the code and add an existing language feature of Python and Kotlin.
Cost Description
No response
Changes to Go ToolChain
gofmt, gopls, vet.
Performance Costs
No response
Prototype
No response
The text was updated successfully, but these errors were encountered: