lua-users home
lua-l archive

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

2010/1/9 David Manura <>:
> On Sat, Jan 9, 2010 at 11:23 AM, Matthew Wild wrote:
>> But require() should be the one that sets the global (if it must) and
>> return the module (I prefer this) into the caller's environment.
> I had come to the same conclusion: The policy of how a module is
> imported should be caller's decision (require), not hard-coded into
> the module definition (module).  Granted, it has been said that the
> caller can redefine "module" prior to doing "require" and therefore
> adjust policy

Overriding module() would work only for Lua modules. I can't override
luaL_register(), which is why I patched require() this way.

luaL_register() is the recommended way to implement C libraries,
everyone does it... I don't fancy changing this in every library I