lua-users home
lua-l archive

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


> -----Message d'origine-----
> De : lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] De la part de Javier Guerra Giraldez
>
> in any case, being a vector (which the array part of Lua's table
> already is) doesn't make any easier to find the highest integer key
> without a linear search at some point.

The idea would be that with a true vector, there is no such thing as a hole (absent key), and iterating over vector elements can perfectly yield a [scalar/nil] pair without aborting the loop. For a vector, operator # *is* the same thing as std::vector::size(). Thus the highest integer key is the vector's size, and the values can be anything you want, and nil isn't a special case that breaks iteration, just a value like any other.

Anyway, this is just noise since we are unlikely to see this happen someday (at least not in my lifetime :-).