3 ms·
Lua's tables go further in a few respects. one is that anything can be a key, including other objects, which makes certain things much easier another is Lua's
by tokipin 19y ago
Lua's tables go further in a few respects. one is that anything can be a key, including other objects, which makes certain things much easier
another is Lua's metatable system, which lets you specify the behavior of the table under various operations. one of the interesting ones is the operation of accessing an index that doesn't have an entry in the table, which leads to straightforward ways of implementing inheritence and memoization, among countless other things
Lua's tables also entirely subsume arrays and other key-value pair thingies at minimal performance loss. tables are also used across the language in various places. for example, you can set a function's variable environment with a table, which is how modules are officially implemented
not to make an offhand comparison, but because Lua and Javascript are quite close
- benreesman 19y agoUpmodded for the thoughtful and informative reply. I really need to take a look at Lua, there seems to be a lot of momentum building around it.