lua-users home
lua-l archive

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


> The behavior defined by the Lua 5.3.0 documentation, where the
> iteration runs from 1 to #t) looks acceptable to me, even though its
> implementation seems - by principle (as explained above) - inefficient
> to me.

Do you have any real data to back your worries? Among other things,
if you are providing your own __len metamethod, it most probably
returns the value of some count associated with the array, and therefore
is O(1), not O(log n). So, by principle, this implementation should
not seem inefficient. (Never mind that quite probably this O(1) is slower
than Lua's built-in O(log n) length anyway :)

-- Roberto