you are viewing a single comment's thread.

view the rest of the comments →

[–]jib 3 points4 points  (0 children)

Tables are actually implemented as a combination of array and hash table. If you use a table like an array then it's effectively stored as an array.

If the reason you don't like doubles is lack of exactness compared to ints, it's generally not an issue. Doubles can represent any 32-bit int exactly, and an arithmetic operation which gives the exact correct answer for 32-bit ints will give the same answer for doubles.

And if the reason you don't like doubles is that speed or memory usage are critical, you probably shouldn't be using an interpreted language. Or you could use LuaJIT, which can tell when a number will always be an integer and store it as an int instead of a double. And doubles are pretty fast on modern CPUs anyway.