lua-users home
lua-l archive

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


* Roberto Ierusalimschy:

> Yes. We are changing the policy that modules should define globals.  We
> changed environments. We think now the 'module' function adds too much
> complication for something that it is easy to do directly.

How would you do it directly?  Something like this?

  local _M = []
  in _M do
      function globalfunction()
          -- ...
      end
  end
  return _M

Conceptually, in/do/end could be an expression returning the table,
leading to "return in {} do --[ ... ] end".

I'm a bit worried about lack of a common idiom for setting up modules.
Perhaps the module loader should take care of such details?