lua-users home
lua-l archive

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


In face of recent (long) discussion about "Lua arrays", I would request a simple few lines of real world examples where the use of "Lua arrays with holes" is significant.
I known that, intuitively, the length operator # should return the "size" of the array, but I'm not able to find significant use cases where "holes" are, in fact, a real problem other than a *simple* algorithm redesign.

For my particular use case I made heavy use of "sparse things", from which Lua tables are awesome, where all computations are based on the keys, namely, with pairs() or indexing the relevant key. Also, I use "proper sequences" with Lua tables. In this case, table.pack and table.unpack are symmetric, and the relevant computation is given by the "order" of the keys, namely, with table.insert, table.remove, table.move etc that is by default, in this case, simple to understand. I never ever used a "Lua array with holes", where the ordering, or existence, of the keys is indeed relevant for computation. Precluding the use of __len or misbehaviour of  #.

Could you help me giving a (real world) counterexample?

--
Rodrigo Azevedo Moreira da Silva