FAQ
I wrote this comment.

Simplifying s[x : len(s)] to s[x :] seems like it's always a good idea
because it reduces clutter and duplication; while simplifying s[0 : x] to
s[: x] is not such a big deal. I felt more strongly about this in the past
(if I remember correctly, at first only the 2nd index was made optional -
we changed it later for symmetry). That said, sometimes it's still
desirable (for pedagogic or readability reasons) to write the explicit 0.
It's also fairly easy to make the rewrite with -r if so desired.

- gri


On Tue, Oct 1, 2013 at 7:10 AM, rh wrote:

gofmt/simplify.go contains the note:

// 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.

What is the rationale here? When is explicitly specifying a lower bound
of 0 helpful?
The comment currently does not expound on this.

--

---
You received this message because you are subscribed to the Google Groups
"golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 8 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 1, '13 at 4:27p
activeOct 1, '13 at 7:50p
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase