News for hackers. Stuff that matters.
Re:Why do arrays start at 0? by nicoburns on Wednesday August 24, 2022 @01:06PM (#32582455)
That's just convention though. There's no reason "[x]" couldn't have been defined to be "+ (x - 1) * sizeof". There would be no runtime cost to this, and the compile time penalty would be tiny even on ancient systems.
Re:Why do arrays start at 0? by nwlieb on Wednesday August 24, 2022 @01:29PM (#32582780)
Is `(x - 1)` not a runtime cost if `x` is a runtime variable?
Re:Why do arrays start at 0? by vikingerik on Wednesday August 24, 2022 @02:57PM (#32584103)
Not on many instruction architectures - addressing modes often support adding/subtracting a constant.