lua-users home
lua-l archive

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


OK, most probably I didn't make myself clear enough. Maybe I should better
have said that one cannot create the module 'mymodule.assert' or
'mymodule.error' once the module 'mymodule' were previously created using
the module function. This happens because all global variables are
accessible through the table of a module (in this case, the table
'mymodule'). This way 'compat-5.1.lua' thinks there is some conflict at

I can see it happening now. I am not sure if the best idea is to use rawget
in getfield. There might be a use for the __index metamethod in a
namespace other than exposing the global variables through it. I would
instead require the writer of mymodule to clear out the __index
methamethod, so that globals are not visible. It can be done with a line
such as

    getmetatable(_M).__index = nil

in the end of mymodule.lua. Either this, or the writer of mymodule.error
can do it instead.