|
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Kristofer
Karlsson
My “count” works on
all tables not just arrays, so yes it uses next() (actually lua_next() as it is
implemented in C). t[1] would be fast, but incomplete as a table is not
necessarily (or even typically) empty if that element is null. I do not get
your point – when counting elements using next it must be more efficient
to terminate the traversal as soon as you have your answer rather than
traversing the entire table. I disagree that Lua should have different data types for arrays
and dictionaries – what about all the other data structures such as sets
and lists for example? Lua should provide the tools for implementing these, not
the implementations. But a true table count would be one such tool that would
improve the possibilities for such implementations. |