lua-users home
lua-l archive

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


On 16 October 2011 18:51, Petite Abeille <petite.abeille@gmail.com> wrote:
>
> On Oct 16, 2011, at 7:24 PM, Roberto Ierusalimschy wrote:
>
>>> In 5.1, one can easily bundle multiple modules per Lua file, or
>>> concatenate multiple modules into one file, or package the entire
>>> enchilada in one binary file, courtesy of luac, without any fuss.
>>
>> In Lua 5.2, I think you can easily write something like the following,
>> for multiple modules in one file:
>>
>> do   -- Module 1
>>  local _ENV = mymodule("mod1")
>>  ...
>> end
>>
>> do   -- Module 2
>>  local _ENV = mymodule("mod2")
>>  ...
>> end
>>
>> where 'mymodule' is a somewhat trivial function.
>
> As oppose to:
>
> module( 'mod1' )
>
> ...
>
> module( 'mod2' )

... Error: attempt to call global 'module' (a nil value).

module() is too magic in my opinion.

Regards,
Matthew