4 ms·
I'm not a Lua user, so I thought I'd ask why one-based indexing is a flaw. As long as it's consistent, does it really matter? As someone who is forced to use V
by airstrike 8y ago
I'm not a Lua user, so I thought I'd ask why one-based indexing is a flaw. As long as it's consistent, does it really matter?
As someone who is forced to use VBA, it sounds like Lua could be worse
- jonsen 8y ago“Why numbering should start at zero”: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
- umanwizard 8y agoIf x is some object then x[k] is intuitively some object at distance "k" from the beginning of x. So the object right at the beginning is x[0].
- bunderbunder 8y agoI have spent limited time with Lua - mostly just fiddling with pico-8. My experience has been that it's fairly easy to get used to, but occasionally annoying. For example, it doesn't interact nicely with modular arithmetic the way 0-based indexing does.
- renox 8y agoBecause Lua is often used as an extension language of C++ which has 0-based indexing: it's really painful for programmers to switch from one indexing to another.
- ghusbands 8y agoIf you store a 2d array in a 1d one, it's natural to try/use x+200*y or such. With 0-based indexing it just works. With 1-based indexing, it's more complicated. If you do any modulus-based array access, 1-based indexing makes it more complicated. Basically, a world with 0-based indexing results in simpler math than a world with 1-based indexing, making it the better choice.