lua-users home
lua-l archive

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


No, the manual is correct.

Consider the following example code (run on Lua 5.1.4 on a ubuntu machine)
return #{nil, nil, 1}
--> 3
return #{nil, nil, 1, nil}
--> 0

/Kristofer


On Wed, May 19, 2010 at 12:47 PM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
Just on a point of language in 3.4.6:

Surely

"The length of a table is defined to be any index such that .... "
is incorrect.

Should it not be

"The length of a table t is defined to be the least non-negative
integer n such that t[n+1] is nil and t[m] is non-nil for any
positive integer less than n+1."?

I know my phrasing is longer but as the manual stands in the case that
t[1] = nil, t[2] = 0, t[3] = nil
it would imply that #t = 2.

Or should the phrase

"moreover, if t[1] = nil, n can be zero"

really be

"moreover, if t[1] = nil, n must be zero"

?



--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/