[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: from: Lua Module Function Critiqued
- From: Tom N Harris <telliamed@...>
- Date: Tue, 08 Oct 2013 21:02:18 -0400
On Monday, October 07, 2013 03:15:15 PM Andre Arpin wrote:
> This is verbatim from the wiki.
>
> (function()
> local require = require
> local print = print
> local module = module
> module("yourmodule");
>
> (function() module("mymodule") end)()
>
> print(mymodule ~= nil) -- prints false (where is it?)
> end)();
This led me to discover something interesting.
(function()
local print = print
local module = module
module("yourmodule")
print(module) -- function: 0x108f960
(function()
module("mymodule")
end)()
print(module) -- table: 0x10b0470
end)()
The module function is mutating the first upvalue of the calling function
without regard to whether it is the _ENV table.
--
tom <telliamed@whoopdedo.org>