lua-users home
lua-l archive

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

>>>>> "Dirk" == Dirk Laurie <> writes:

 >> The newer implementation of ipairs() does not honour if __ipairs
 >> returns more than 2 values.

 Dirk> There is no such thing as "the newer implementation of ipairs()".

Yeah, there is.

5.2 (and 5.3 with COMPAT_IPAIRS) have the implementation "if an __ipairs
metamethod exists, call that and return its 3 results, otherwise return

5.4 (and 5.3 without COMPAT_IPAIRS) has the implementation
"return ipairsaux,t,0"

I continue to maintain that deprecating __ipairs is the wrong move and
that it should be reinstated. Just having ipairsaux() respect
metamethods is NOT sufficient for all cases that __ipairs is useful for.

 Dirk> The 5.4 manual says exactly what the 5.3 manual said, that ipairs
 Dirk> "Returns three values (an iterator function, the table t, and 0)",

 Dirk> and in fact the __ipairs metamethod still works as in 5.3, with
 Dirk> 'ipairs' adjusting the number of return values from __ipairs to
 Dirk> exactly three, without checking them in any way.

This is NOT THE CASE. In 5.4, __ipairs will never be called; there is
literally no such metamethod.

You also completely missed the original point, which is not that
__ipairs itself could return more than 3 values, but that the iterator
function that it returns could do so.