lua-users home
lua-l archive

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


On 19 October 2011 21:24, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> Certainly an improvement from handling the module table explicitly
>> (and no segfaults this time). But having basically the same function
>> being provided by the loader[1] would obviate the need for explicitly
>> mentioning _ENV.
>
> I think explicitly mentioning _ENV is good. If you are working with
> a different global environment, why hide that information? Moreover,
> a modified 'load' function forces everyone to live with its magic.
>

Agreed. Also if someone doesn't want to change the environment, but
just use the other features of module() they can simply

   local mymodule = module("mymodule")

   function mymodule.myfunction()
   end

You can even name this table 'exports', for those missing Node.js :)

Regards,
Matthew