lua-users home
lua-l archive

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


> The problem with that implementation of the # operator is that some people
> rely on the fact that t[#t+1] is always nil to add elements to the table

This is documented behaviour for Lua 5.1 but not for Lua 5.2.
Numerous previous semi-ignorant posts on this list provoked
the Lua team to remove that information from the specification.

A lose-lose non-solution, caused by threads just like this one.

Heck, people, the Lua team has gone out of their way to
solve the #t issue by providing the __len metamethod:
if you don't like #t as supplied, you can change it to anything
you like.  Don't talk about it, do it.

But Roberto, if you are still reading this thread (in your place
I would have blacklisted it long ago): you may as well bring
back the t[#t+1]==nil property into the documentation.  Its
absence is clearly not sufficient to stop people from
yammering about the length function.