-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reverse indexing should be 0-based #3
Comments
While i agree with the comparison, having ^0 be the -1st item will be very confusing. |
@jridgewell This question is well answered here: Why doesn't the new hat-operator index from the C# 8 array-slicing feature start at 0? The main motivation of index from end syntax is not for iteration (which I believe reverse iterable would be a feature to satisfy such use cases in a better form), but for random accessing from end, and slice notation, in those cases, make Note, of coz we could consider using C++ rbegin model, but:
|
@jridgewell this would directly go against my being able to do |
As previous discussions, I think as the goal and constraint of this proposal and related proposal, it's very unlikely we could make a syntax using I add a FAQ item in README to link back to this issue, so if people have similar concerns they can continue the topic here, and we can reopen if needed. |
I want make a parallel to regular forward indexing, and the easiest example is array iteration:
This form of
= 0
,< array.length
,i++
is soooo common it's burned into my mind. Importantly, forward indexing is 0-based.Now, compare that to the 1-based reversed indexing currently proposed:
That
= 1
and<=
is going to drive me crazy. It seems like if make reverse indexing 0-based instead, we can mirror C++'sstd::rbegin
(which is a 0-based iterator, it immediately points to the last item):The text was updated successfully, but these errors were encountered: