lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 23.07.2016 um 18:45 schröbte Soni L.:
Many people on this list say tables have an "array" and a "hash" part.

That's what they are called in the Lua source code[1]:

Tables keep its elements in two parts: an array part and a hash part.


I'd think a table has a "sequence" and "map" part instead. For example,
a map doesn't necessarily have to be a hash map, you can implement maps
with binary trees and/or tries instead, and a sequence doesn't
necessarily have to be an array; a linked list is a sequence but not an
array.

But Lua tables are implemented as hash tables with an array for optimized storage of small integer keys, not as trees or linked lists. Since the array/sequence/array part situation is complicated enough already, and the array part is an implementation detail anyway, let's better not add new names.

Actually, let's better not mention it at all unless the question is "Isn't storing array-like data in a Lua table terribly inefficient?".


Philipp

  [1]: https://www.lua.org/source/5.3/ltable.c.html