[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Documenting Lua gotchas for newbies.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 3 Dec 2010 10:39:30 -0200
> [*] Of course, this is a minor problem compared to explaining the
> weird behavior of the # operator. I predict it will be changed to
> return the actual number of elements of a table sometime around Lua
> 7.0 (when the argument that not maintaining a counter saves precious
> memory and processing won't be as compelling), [...]
The problem with # returning the actual number of elements of a table
is not space, but that it does not solve most of the real problems that
the current # have. It sure becomes deterministic, but mainly useless
nonetheless. #{1,nil,1,nil,1} being 3 is not very helpful when you think
about a list with holes. Doing "a[#a + 1] = nil" will still not work
with that scheme (in the same way it does not work with the current
one).
-- Roberto