<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://petitplanet.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ANo_globals</id>
	<title>Module:No globals - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://petitplanet.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ANo_globals"/>
	<link rel="alternate" type="text/html" href="https://petitplanet.wiki/index.php?title=Module:No_globals&amp;action=history"/>
	<updated>2026-04-10T02:39:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://petitplanet.wiki/index.php?title=Module:No_globals&amp;diff=12&amp;oldid=prev</id>
		<title>Stevium: Created Module:No globals</title>
		<link rel="alternate" type="text/html" href="https://petitplanet.wiki/index.php?title=Module:No_globals&amp;diff=12&amp;oldid=prev"/>
		<updated>2025-11-09T08:24:09Z</updated>

		<summary type="html">&lt;p&gt;Created Module:No globals&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--  &amp;lt;pre&amp;gt;&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Source: https://dev.fandom.com/wiki/Module:No_globals&lt;br /&gt;
--- No globals prevents nil global variables from being written to or read.&lt;br /&gt;
--  This module greatly reduces the chance of errors from overriding globals.&lt;br /&gt;
--  &lt;br /&gt;
--  To use the module, add the following code below your module table&lt;br /&gt;
--  definition:&lt;br /&gt;
--  &lt;br /&gt;
--  {{#tag:pre|require(&amp;#039;Module:No globals&amp;#039;)}}&amp;amp;#010;&lt;br /&gt;
--  &lt;br /&gt;
--  The @{require} function sets the `arg` global in the package library when&lt;br /&gt;
--  loading a module - see the [source code](https://git.io/JfKu8) in Scribunto&lt;br /&gt;
--  core. To ensure Scribunto can load modules, the `arg` global is whitelisted.&lt;br /&gt;
--  &lt;br /&gt;
--  @script             getmetatable(_G)&lt;br /&gt;
--  @alias              mt&lt;br /&gt;
--  @release            stable&lt;br /&gt;
--  @note               This module has been adapted as a library in &lt;br /&gt;
--                      [[mw:gerrit:q/834623|MediaWiki core]], called as&lt;br /&gt;
--                      `require(&amp;#039;strict&amp;#039;)`.&lt;br /&gt;
--  @author             [[wikipedia:User:Jackmcbarn|Jackmcbarn]] (Wikipedia)&lt;br /&gt;
--  @author             [[User:Dessamator|Dessamator]]&lt;br /&gt;
--  @attribution        [[wikipedia:Module:No globals|Wikipedia]]&lt;br /&gt;
local mt = getmetatable(_G) or {}&lt;br /&gt;
&lt;br /&gt;
--- Read access restriction on @{_G} global table.&lt;br /&gt;
--  @function           mt.__index&lt;br /&gt;
--  @param              {table} t Global table - @{_G}.&lt;br /&gt;
--  @param              k Indexed key.&lt;br /&gt;
--  @error[opt,28]      {string} &amp;#039;tried to read nil global $k&amp;#039;&lt;br /&gt;
function mt.__index(t, k)&lt;br /&gt;
    if k ~= &amp;#039;arg&amp;#039; then&lt;br /&gt;
        error(&amp;#039;Tried to read nil global &amp;#039; .. tostring(k), 2)&lt;br /&gt;
    end&lt;br /&gt;
    return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Write access restriction on @{_G} global table.&lt;br /&gt;
--  @function           mt.__newindex&lt;br /&gt;
--  @param              {table} t Global table - @{_G}.&lt;br /&gt;
--  @param              k Indexed key.&lt;br /&gt;
--  @param              v Value to be assigned.&lt;br /&gt;
--  @error[opt,42]      {string} &amp;#039;tried to write global $k&amp;#039;&lt;br /&gt;
function mt.__newindex(t, k, v)&lt;br /&gt;
    if k ~= &amp;#039;arg&amp;#039; then&lt;br /&gt;
        error(&amp;#039;Tried to write global &amp;#039; .. tostring(k), 2)&lt;br /&gt;
    end&lt;br /&gt;
    rawset(t, k, v)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setmetatable(_G, mt)&lt;/div&gt;</summary>
		<author><name>Stevium</name></author>
	</entry>
</feed>