-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: Go 2: expand power of range for slices/arrays #36816
Comments
Additional Notes:
|
Would you mind filling out the template in https://go.googlesource.com/proposal/+/bd3ac287ccbebb2d12a386f1f1447876dd74b54d/go2-language-changes.md ? Thanks. |
where do I save it? |
Add it as a comment to this issue. Thanks. |
Iterating from the middle seems like too rare a use case to bake into the language - I've personally never encountered it. Iterating in reverse is something I've needed a few times myself; it may be worth adding, if only to help avoid off-by-one errors. I think the syntax you're proposing is too cryptic, though. I would rather implement this as a |
While this is clever, I'm not sure if I like it. Go has very few symbols that aren't universally understood ( |
The middle-out range is rarely useful, and the syntax is cryptic. That doesn't seem like a good addition to the language. How often does one want to iterate backward? It's already possible to do so, in a way that is clear and easy to understand. The single Also, the Iterating backward can be done with the usual for i := range s {
v := s[len(s) - 1 - i] // reverse iteration
...
} This proposal does not seem compelling. |
This proposal wishes to expand the power of the
range
keyword when applied to slices and arrays.Note: If you don't want to use the features, your code will LOOK EXACTLY THE SAME.
Currently:
Proposal:
+
)The text was updated successfully, but these errors were encountered: