Commit a51b8cf8 authored by Robert Hencke's avatar Robert Hencke Committed by Rob Pike

gofmt: explain why lower bounds aren't automatically simplified

Full credit goes to gri and rsc for their explanations.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14229043
parent fe1c92a2
......@@ -90,6 +90,10 @@ func (s *simplifier) Visit(node ast.Node) ast.Visitor {
// Note: We could also simplify slice expressions of the form s[0:b] to s[:b]
// but we leave them as is since sometimes we want to be very explicit
// about the lower bound.
// An example where the 0 helps:
// x, y, z := b[0:2], b[2:4], b[4:6]
// An example where it does not:
// x, y := b[:n], b[n:]
case *ast.RangeStmt:
// a range of the form: for x, _ = range v {...}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment