Closed
Description
I propose that Go adds checked
and unchecked
keywords for arithmetic operations that function like those of C#. This is somewhat similar to the Go 2 error handling proposal.
This is related to #19624. If #19624 is accepted, then cases like hash64.go could be handled by wrapping the calculations in an unchecked
block, which is a cleaner solution than anything I saw presented on #19624.
Blocks
checked {
x := a * b
y := a + b
z := x^y
}
unchecked {
x := a * b
y := a + b
z := x^y
}
Statements
It would be difficult to allow checked
and unchecked
to be used on statements without breaking backwards compatibility or making it confusing. The possibilities that occur to me are A) not bothering (only supporting blocks), B) unchecked(a * b)
, or C) unchecked a * b
.