lua-users home
lua-l archive

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

> A simple way to handle this can be to slightly modify the definition of
> the array part of a lua table :
> #t is the biggest 'n' such that all values t[1], ..., t[n] are not nil.
> The array part of a table 't' is a sub-table t[1], ..., t[#t].
> In this case we have a perfectly deterministic array without holes. The
> cost to do this is negligible. (The implementation can continue to store
> other keys after a hole in the array part of the table structure for
> efficiency but these are not exposed to lua as part of the array)

Can you be more specific about this implementation? I don't see how to
ensure that all t[1]...t[n] are not nil without either traversing them
all or keeping extra information and slowing down table modifications.

-- Roberto