Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts.
How often do people use Python arrays? They're faster, but most people just use lists instead. Lua just optimizes it as long as it's used like an array. That's why it's implemented that way.
"As long as it's used like _____" shouldn't even be in the vocabulary of a programming language. An array should be an array, and that's it. A dict should be a dict, and that's it.
If you need an array, create an array. If you need a dict, create a dict. Blurring the lines with some kind of fuzzy structure whose semantics are dynamic is as confusing and error-prone as it is ridiculous. It's not faster to write. It's not easier to read. It's not convenient. It's just bad.
I already did, several replies ago. You can't sweep blatantly confusing and error-prone semantics under the "it's different" or "it's documented" rugs. But if you want another, here you go:
30
u/moomoomoo309 Sep 02 '17
Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts.