5 ms·
Zero based indexing doesn't make any sense. You start counting at one, not zero. It causes confusion. Lua's universal tables also simplify things and aren't th
by Houshalter 12y ago
Zero based indexing doesn't make any sense. You start counting at one, not zero. It causes confusion.
Lua's universal tables also simplify things and aren't that less efficient.
- krapp 12y agoArrays start at zero because what you're counting is how far you're moving a pointer from the initial address in memory, not the items themselves. Array[0] is literally 'read what's at pointer sizeof(n)+0 from the start.' Zero-based indices make perfect sense when you know what they actually indicate. Although to be fair, starting with one and actually counting the items makes sense too, and seems more intuitive, and this may not even apply to Lua at all. But one-based indexing is still wrong regardless.
- sitkack 12y agoa) it doesn't matter b) lua doesn't have these pointer things you speak of. If you are going to hate on 1 based indexing at least have the fine style of EWD.
- krapp 12y agoOff by one errors are enough of a problem without having to remember that lua decided [1] means something other than what [1] means in almost every other language, so plan accordingly. It's not critical, but it does matter.
- sitkack 12y agoc) the audience. Lua was designed a scripting and data environment to run simulations in Fortran. So the customer was already using 1 based indexing. https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
- krapp 12y agoWell... Fortran sucks.
- frou_dh 12y ago> Zero based indexing doesn't make any sense. Ordinal and cardinal are different. There's nothing left to debate. (Also, time to start a petition to move the 0 key to be before the 1 key on the standard keyboard layout ;)