-
Notifications
You must be signed in to change notification settings - Fork 16
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
Inclusive vs exclusive indices for preceding/following #92
Comments
Correct.
We need |
OK, thanks for the explanation. I can see some elegance in the symmetry between Virtually all programming languages, including JavaScript, have come to agree that the left index should be inclusive, and the right index should be exclusive, and that's the intuitive behavior that I would want to expect from this API. Separately, I've always thought of indices as a cursor pointing between two elements of an array:
If |
I would also be happy if we had a new method If we do this, consider renaming |
We could switch to the asymmetric behavior you're after, but I don't want to do so with the current antonym pair. What would you think about this refactoring?
|
Sure, in my opinion, your suggestion is better than the status quo. Another idea:
|
I'm glad to see some thoughts here from a use case perspective. Lots of interesting ideas here; I guess we need to come to a conclusion before Stage 3. |
If we make the random-access methods stateless as proposed by #93, then I expect to define If they instead remain state-mutating, then I'm thinking more and more that indicating that with verbs is important, and would want an |
@gibson042 , @sffc and I discussed this issue in a call, and agreed that the |
Resolved in favor of |
We also discussed that
|
I want to get the segment containing the code unit at index i. How do I do it? Basically, what I want is:
Reading the spec, it appears that both following and preceding use an exclusive index. So, I think I could get what I want by using
.preceding(i+1)
or.following(i-1)
. But, that doesn't seem as nice to me. Personally, I would find it more intuitive if.preceding()
used an exclusive index, and.following()
was inclusive, such that.following(i)
gave me the behavior I want.The text was updated successfully, but these errors were encountered: