lua-users home
lua-l archive

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


> On 1 Aug 2010, at 14:33, Roberto Ierusalimschy wrote:
> >Yes. We are changing the policy that modules should define globals.
> 
> What do you mean by that? I thought this always has been up to the
> module developer and the 'module' function was just to aid the
> developer doing something considered an usual practice.

It was and still it is up to the developer to choose whether to create
globals. Now the "usual practice" seems so simple that it does not
deserve a helper function. Just write this:

   _ENV = {}
   ...
   return _ENV

Note that you do not need to make _ENV local. Using the upvalue _ENV
allows easier hacking, as all modules will have their table in upvalue 1
of its main function.

-- Roberto