|
The 5.3 beta docs state, for ipairs(): "Returns three values (an iterator function, the table t, and 0) so that the construction for i,v in ipairs(t) do body end will iterate over the pairs (1,t[1]), (2,t[2]), ..., up to the first integer key absent from the table." My reading of “absent from the table” is “that returns nil as its value”. Note that this makes no mention of the # operator or the __len() metamethod. Again, my reading of the docs is that ipairs() in the 5.3 beta doesn’t even use # or __len(). For comparison, the 5.3 alpha (earlier) docs read: "Returns three values (an iterator function, the table t, and 0) so that the construction for i,v in ipairs(t) do body end will iterate over the pairs (1,t[1]), (2,t[2]), ..., (#t,t[#t]). The table should be a proper sequence or have a __len metamethod (see §3.4.7).” In fact, if you believe the docs (as i think people should), ipairs() int 5.3 beta (and presumably the release as well unless it changes again), __len is not involved at all, and can return whatever it likes with no effect on ipairs(). I’ve not tested this, but if ipairs() DOES respect __len() in some way on 5.3 beta, then imho either the code or the docs are wrong. —Tim |