@technomancy @akkartik Also worth noting for those metamethods, if you're already working from C, is the native patch approach as seen in the Lua wiki http://lua-users.org/wiki/GeneralizedPairsAndIpairs
Though in the case of __ipairs you get the extra confusion of the fact that Lua 5.3 went on to deprecate it and 5.4 to remove it in favor of making ipairs respect __index and __len :(
@technomancy @akkartik Correction: ipairs respects __index and stops when it hits a nil, it doesn't check __len.
Not sure what I conflated it to throw __len in when I misremembered but figured I should correct myself after @technomancy asked me about it!