TL;DR Can we get rid of the end
token in favor of negative indices, and can we display empty rages consistently?
I wondered why the end token is necessary, instead of just using negative indices.
This was probably asked before, but it’s a difficult search term and not explained in the docs as far as I noticed.
(I think negative indices would be more consistent, because Julia’s indices start at 1 by default, so reverse indices should start at (-)1 as well instead of 0 (end - 0).)
So I thought, it might be because it conflicts with ranges with negative indices, so I played around with that.
I noticed that a range where the second number is smaller than the first always returns a range where the stop value is one smaller.
E.g. 5:2
, 5:-1
all return 5:4
.
Is that intended?
(see https://github.com/JuliaLang/julia/blob/f383276c5b91d4d111f628c2eaa6b2db2f496421/base/range.jl#L155-L156)
Chris Rackauckas told me on Gitter, that they’re displayed identically, because they’re all the empty range, but I didn’t find that very intuitive… maybe it would be useful to have a standard way of displaying an empty range regardless of its indices?