-
Notifications
You must be signed in to change notification settings - Fork 218
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
Documentation for out-of-bound accesses with single index vs slices #943
Comments
@Poshi you're right, the documentation is not clear. I very intentionally imitated Python's behavior here, but didn't document that fact ... |
OK I didn't entirely even mimic Python behavior as intended. :( Keeping in mind Python indices are 0-up, with lower-inclusive-upper-exclusive, while Miller indices are 1-up, with lower-inclusive-upper-inclusive:
So for the first thing
-- I stand by my intention to mimic Python here. For the second thing
-- you are quite right, and I'm embarrassed to realize I missed this. :( |
For arrays, I did what I intended:
|
Just checked the three commits. Looks good! The new code seems OK. I'm not sure if some checks can be reduced, but they look fine. (I've also been lost a couple minutes when the index went down to zero until I realized the difference between "index" and "Zindex"). |
According to the documentation:
This is somewhat ambiguous: if out-of-bound index accesses are errors, it is surprising the an slice access does not trigger the same error. Would not make sense to return the same as in the slice access: an absent value?
Also, the examples below show:
If we take for good that out-of-bound slice accesses can result in short strings, should not the second access (
x[1:6]
) result in the short string"abcde"
? (It is a short string because the slice should return a 6 characters string but the result only contains 5).The text was updated successfully, but these errors were encountered: