4 ms·
Love the language and how much has grown, but could never get past the 1-based indexing of table arrays.
by lastdong 4y ago
Love the language and how much has grown, but could never get past the 1-based indexing of table arrays.
- hypertele-Xii 4y agoI like it, feels more natural and intuitive to me somehow. The presence of zero should be special; it doesn't quite feel like "just another number".
- vaylian 4y ago... until you get into modulo arithmetic and then things come crashing down.
- samatman 4y agoHonestly, I've relaxed about that part quite a bit. Array tables are usually iterated with `ipairs`, appended with `insert`, popped with `remove` and so on. The difference between putting new stuff at `tab[#tab]` (the usual) and `tab[#tab + 1]` (the Lua style) just doesn't come up much. What is a genuine mistake, which I'll never get over, is the one-based semi-open interval string indices. Representing the spot before the first character as `1,0` is just awful, and it has real consequences for interval arithmetic, which is frequent with strings. The bugs are usually shallow, but I get really creative with cursing when I see something moved by two bytes, because I got the sign wrong on some fencepost arithmetic. pretty simple: is it (a - b + 1), (b - a + 1), (a - b - 1), or (b - a - 1)? There should only be two options. That said, it's pretty fantastic to use a language with a flaw, rather than a flawed language. I would definitely change how strings are treated, if I could, and yeah, probably zero-index tables as well, but that's about it. The lack of multiple return values in Python, requiring changes to every call site if you decide a tuple is better than a scalar, is dramatically worse than this, and I don't see people complaining much.
- CapsAdmin 4y agoHaving used Lua and other zero indexed languages for a while, it's not that different from switching between a mac keyboard and windows keyboard. It can be annoying in the beginning, but your brain figures it out eventually.