// ProxyPairs implements Lua 5.2 'pairs' functions. // It respects the __pairs metamethod. // // It is only useful for compatibility with Lua 5.1. func ProxyPairs(L *lua.State) int { // See Lua >=5.2 source code. if L.GetMetaField(1, "__pairs") { L.PushValue(1) L.Call(1, 3) return 3 } L.CheckType(1, lua.LUA_TTABLE) L.PushGoFunction(pairsAux) L.PushValue(1) L.PushNil() return 3 }