lua-users home
lua-l archive

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


IMHO "if ever had" instead of has is simply a bit you can set whenever
there is a non-linear insertion/omission.

t[3]=3, t[2]=2, t[1]=1

table.hadeverholes(t) --> true

also believe this will raise complaints, as some people sure rely on
#t to be defined 3 in this case.

I'm personally do no longer care what # results on non-lists, but my
impression of Lua presentation was to provide less easy to do
undefined behaviors (whereas in C they are very easy to do). And thus
I think any # that always results the same for the same set of keys
(no matter in in which way created) would be preferable, as many
non-expert coders try their Lua code out, and if it works they suppose
it will work anytime, not aware that the result of # on a non-list
might differ depending on the lua core, jit or nonjit, or phase of the
moon. On non-lists the one and only use of # I see is insertion. Its
great that table.insert uses it, but thats all there is to it.

On Thu, Dec 30, 2010 at 3:41 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> Has it been pointed out, if/why it would be costly to throw an error for
>> #t if a list t ever had holes?
>
> The message by uki before yours says it all: "there is absolutely no way to
> check if the table has holes, except by iterating through the whole table."
>
>