no u :^) XDXDXDXD
Special snowflake languages
Not him, but using an array as a circular data structure, that is, you insert at the end and when you reach the array size you wrap back to the beginning, is an example of an application where 1-indexed arrays have a subtle caveat:
0-index: a[i%size] = element; ++i
1-index: a[(i%size)+1] = element; ++i
I know that it looks like bullshit, but if off-by-one issues were that simple there wouldn't have been decades of buffer overflow exploits
That makes sense. Of course there are cases in which 0-indexing is more natural. But that doesn't necessarily mean that 0-indexing is more natural in the majority of cases.
If only there were languages that would let you choose any range of any discrete type to index your array's.
You could also do it by resetting the counter.
0-index: a[i] = element; if i = length(a) - 1 then i = 0;
1-index: a[i] = element; if i = length(a) then i = 1;
That's worse than forcing either of them, because you then have to keep in mind what kind of array you're dealing with, and if you forget you end up making mistakes. It gets especially bad when you're working with code someone else wrote.
you really are brain dead
oh right wrapping around an array makes sense but accessing every nth element is so out there that you can't even imagine it. holy fuck
...
Thank you, that was the explanation I was looking for.
This is client side investor tier software. You understand that right?