lua-users home
lua-l archive

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


> On Jun 1, 2015, at 1:13 PM, Coda Highland <chighland@gmail.com> wrote:
> 

> Tables that "have no holes" are a NECESSARY condition for being a
> sequence, but not a SUFFICIENT one.
> 
> It is, however, a sufficient condition for use in ipairs/#t/etc.
> 
> So in other words, you basically said exactly what Dirk was saying already.
> 
> /s/ Adam
> 

OK, since we’re being uber-pedantic today…

The set of “tables that are sequences” is a subset of the set of “tables that have no holes”. In it’s current implementation, the # operator produces a deterministic result on tables that have no holes, and thus ALSO on tables that are sequences. However, the Lua reference only guarantees that # is deterministic on tables that are sequences. Thus, using # on a table that contains non-integral positive numeric keys is technically not supported and could break in a future implementation.

—Tim