|
|
|
|
|
by leiroigh
2798 days ago
|
|
One-based indexing obviously means that ranges are inclusive on the right, and you iterate by `for i = 1:length(x)`. That being said, I also abhor 1-based indexing in julia. Well, you get used to it, and it is imho a small price to pay for julia's other cool things. In the end, julia needs to access arrays through pointers, and indirect adressing / LEA use zero-based indexing. Somewhat amazingly, llvm manages to remove/hoist most of the extraneous subtractions. But still, it would be much more transparent if julia simply reflected the hardware standard of zero-based addressing (when in doubt, stay as close to the silicon as reasonably possible). Offset arrays are a bad choice when avoidable, because (1) they incur an additional pointer load, (2) most julia code uses 1-based indices (conforming to common language idioms is always good), and (3) you will trigger all sorts of bugs in all sorts of packages that falsely assume that all AbstractArray are one-based. |
|