module (name [, ···])
Creates a module.
If there is a table in package.loaded[name]
,
this table is the module.
Otherwise, if there is a global table t
with the given name,
this table is the module.
Otherwise creates a new table t
and
sets it as the value of the global name
and
the value of package.loaded[name]
.
This function also initializes t._NAME
with the given name,
t._M
with the module (t
itself),
and t._PACKAGE
with the package name
(the full module name minus last component; see below).
Finally, module
sets t
as the new environment
of the current function and the new value of package.loaded[name]
,
so that require
returns t
.
If name
is a compound name
(that is, one with components separated by dots),
module
creates (or reuses, if they already exist)
tables for each component.
For instance, if name
is a.b.c
,
then module
stores the module table in field c
of
field b
of global a
.
This function may receive optional options after the module name, where each option is a function to be applied over the module.