FAQ
Dear gri,

Thank you very much for expounding upon your thinking. I really appreciate
it.

1) May I gut your comment for its spirit, and place underneath the existing
comment in simplify.go? I believe that the why is as important as the what
to capture.

2) Can you give me a small sample where including the explicit 0 helps code
become more readable or pedagogic? This part is for my own feeble mind.

Thank you so much,
Yet another Robert contributing to Go
On Tuesday, October 1, 2013 11:50:27 AM UTC-5, gri wrote:

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 <robert...@gmail.com <javascript:>>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+...@googlegroups.com <javascript:>.
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 | 3 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