<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FindexIpairs</id>
	<title>Module:table/indexIpairs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Atable%2FindexIpairs"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/indexIpairs&amp;action=history"/>
	<updated>2026-04-22T01:57:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/indexIpairs&amp;diff=495375&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/indexIpairs&amp;diff=495375&amp;oldid=prev"/>
		<updated>2026-04-21T12:01:02Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:01, 21 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:table/indexIpairs&amp;diff=495374&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho at 21:04, 23 April 2025</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:table/indexIpairs&amp;diff=495374&amp;oldid=prev"/>
		<updated>2025-04-23T21:04:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local table_get_unprotected_metatable = &amp;quot;Module:table/getUnprotectedMetatable&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local error = error&lt;br /&gt;
local ipairs = ipairs&lt;br /&gt;
local ipairs_iter = ipairs{}&lt;br /&gt;
local pcall = pcall&lt;br /&gt;
local rawget = rawget&lt;br /&gt;
local type = type&lt;br /&gt;
&lt;br /&gt;
local function get_unprotected_metatable(...)&lt;br /&gt;
	get_unprotected_metatable = require(table_get_unprotected_metatable)&lt;br /&gt;
	return get_unprotected_metatable(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local current = {}&lt;br /&gt;
&lt;br /&gt;
-- Iterator used when there is no __ipairs metamethod to deal with.&lt;br /&gt;
local function default_iter(t, i)&lt;br /&gt;
	i = i + 1&lt;br /&gt;
	local v = t[i]&lt;br /&gt;
	if v ~= nil then&lt;br /&gt;
		return i, v&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function index_ipairs(t)&lt;br /&gt;
	if current[t] then&lt;br /&gt;
		return ipairs_iter, t, 0&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local mt = get_unprotected_metatable(t)&lt;br /&gt;
	if mt == nil then&lt;br /&gt;
		return ipairs_iter, t, 0&lt;br /&gt;
	elseif not mt then&lt;br /&gt;
		current[t] = true&lt;br /&gt;
		-- Use pcall(), so that `t` can always be unset from `current`.&lt;br /&gt;
		local success, iter, state, init = pcall(ipairs, t)&lt;br /&gt;
		current[t] = nil&lt;br /&gt;
		-- If there was an error, raise it.&lt;br /&gt;
		if not success then&lt;br /&gt;
			error(iter)&lt;br /&gt;
		end&lt;br /&gt;
		return iter, state, init&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Iterate up through __index metamethods.&lt;br /&gt;
	local parent&lt;br /&gt;
	repeat&lt;br /&gt;
		-- If an __ipairs metamethod is found, use the custom iterator.&lt;br /&gt;
		local ipairs_mm = rawget(mt, &amp;quot;__ipairs&amp;quot;)&lt;br /&gt;
		if not (ipairs_mm == nil or ipairs_mm == index_ipairs) then&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
		-- If __index isn&amp;#039;t a table, use default_iter().&lt;br /&gt;
		parent = rawget(mt, &amp;quot;__index&amp;quot;)&lt;br /&gt;
		if not (parent and type(parent) == &amp;quot;table&amp;quot;) then&lt;br /&gt;
			return default_iter, t, 0&lt;br /&gt;
		end&lt;br /&gt;
		-- If there&amp;#039;s no metatable, use default_iter().&lt;br /&gt;
		mt = get_unprotected_metatable(parent)&lt;br /&gt;
		if mt == nil then&lt;br /&gt;
			return default_iter, t, 0&lt;br /&gt;
		end&lt;br /&gt;
	-- get_unprotected_metatable() will return false if the metatable is&lt;br /&gt;
	-- protected, which means there could be an __ipairs metamethod, so use the&lt;br /&gt;
	-- custom iterator.&lt;br /&gt;
	until not mt&lt;br /&gt;
&lt;br /&gt;
	local iter, state&lt;br /&gt;
&lt;br /&gt;
	return function(t, i)&lt;br /&gt;
		local new_i = i + 1&lt;br /&gt;
		local v = t[new_i]&lt;br /&gt;
		if v ~= nil then&lt;br /&gt;
			return new_i, v&lt;br /&gt;
		-- Use iter() as a fallback.&lt;br /&gt;
		elseif iter == nil then&lt;br /&gt;
			iter, state = ipairs(parent)&lt;br /&gt;
		end&lt;br /&gt;
		return iter(state, i)&lt;br /&gt;
	end, t, 0&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return index_ipairs&lt;/div&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
</feed>