4 ms·
This makes the most sense to me if you look at it backwards. Given that array access starts with zero, what do you call the access parameter? If you call it "of
by elevensies 10y ago
This makes the most sense to me if you look at it backwards. Given that array access starts with zero, what do you call the access parameter? If you call it "offset" from the beginning of the array, then starting at zero makes sense. If you call it "index", or "element", then we have this confusion. The problem to me isn't the choice of the numbering scheme, it is the names and explanation around it.
- goatlover 10y agoWhich makes sense that it's offset for C, but higher level languages like Python, JS, etc should be index based, which would be 1. That's where R, Julia, Matlab get it right.
- waynecochran 10y agoActually Niklaus Wirth did the best thing a long time ago with Pascal ... let the programmer decide the index range for arrays (although he screwed up making the size of the array part of the type). K&R made the best decision for C since it is the most transparent for the hardware.