[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __tostring and string.format
- From: Mike Pall <mikelu-1012@...>
- Date: Wed, 8 Dec 2010 11:07:52 +0100
Arseny Vakhrushev wrote:
> Exactly! But it seems you do not have to have a separate 'n'
> field in plain Lua because unpack works well with
> {...}-constructed tables. For some reason, this behavior is
> different in LuaJIT.
The behavior of # is very well defined, please see the Lua manual.
But it doesn't have a unique result for arrays with holes. Any Lua
implementation may return _any_ of the possible results for it
(e.g. this depends on non-integer keys, too). In fact, it might
return a different result every time you call it!
You simply cannot rely on the result of # for arrays with holes.
Period. So better fix your code and stop wondering.
--Mike