You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So while this was discussed in #113 back in 2016, I wonder if we should revisit this discussion given the recent changes to array slices in #1093.
With array slicing supporting negative indexes, I find it counterintuitive not to have negative indexing in regular array lookups. Especially as we seem to approximate Python's slicing, and Python does have negative indexing.
@sparkprime you made a good argument against it here, I'm curious if you've changed your mind as hinted here.
@mstandley-tempus no, v0.21.0 includes negative array slicing, I'm asking about negative array indexing.
$ jsonnet -version
Jsonnet commandline interpreter (Go implementation) v0.21.0
$ jsonnet -e 'std.slice([0,1,2,3], -1, null, null)' # slicing, this is what was added in v0.21.0
[
3
]
$ jsonnet -e '[0,1,2,3][-1]' # indexing, this is what this issue is about
RUNTIME ERROR: Index -1 out of bounds, not within [0, 4)
<cmdline>:1:1-14 $
During evaluation
$
So while this was discussed in #113 back in 2016, I wonder if we should revisit this discussion given the recent changes to array slices in #1093.
With array slicing supporting negative indexes, I find it counterintuitive not to have negative indexing in regular array lookups. Especially as we seem to approximate Python's slicing, and Python does have negative indexing.
@sparkprime you made a good argument against it here, I'm curious if you've changed your mind as hinted here.
Note: I've had this related PR in go-jsonnet open for a while.
The text was updated successfully, but these errors were encountered: