rvirding/luerl — Issue #5: module/require
Author: rvirding
Created: 2012-02-27 09:35:32+00:00
State: open

This comment came from @snogglethorpe:

"Remember that the "module" function is considered obsolete in Lua 5.2:

Function module is deprecated. It is easy to set up a module with regular Lua code. Modules are not expected to set global variables.

Instead of using the "module" function, it's simpler and cleaner to just use a pattern like:

-- "oinker.lua", my crazy module!
local oinker = {} -- module
function oinker.crazy_fun () ... end
return oinker -- return module

[Note, none of that wackiness with "seeall" etc, no metatables, everything's just nice and straightforward.]"

Is this how module works internally? What happens if a module does set global variables? Is this an error, or just not recommended?