lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 25/02/2010, at 2:38 AM, steve donovan wrote:

> Hi all,
> 
> This is mostly a clean-up release with bug fixes (particularly in the
> dir module) and more robust error checking.

Thanks, Steve!

> It has support for strict mode (see pl.strict) and passes all its
> tests in this mode.

How does strict work with modules?

As far as I can tell, strict.lua (pl's and lua's) both change the metatable of _G.  But inside a module the global environment is _M.  How is _M affected by what you did to _G?
Don't you need to do something like the following?

local require = require
module(...)
require("newstrict")

where newstrict starts:

local GLOBAL_TABLE = getfenv(2)
local mt = getmetatable(GLOBAL_TABLE)
if mt == nil then
  mt = {}
  setmetatable(GLOBAL_TABLE, mt)
end

Now I wonder if you could get newstrict to replace module or setfenv with a version that does this for you.

Any insight?

Cheers,
Geoff