lua-users home
lua-l archive

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


Hallo,

On 4/24/06, Chris Marrin <chris@marrin.com> wrote:
>
> Module used like this:
>
>      module "foo"
>      function bar() ... end
>
> I can put the above into a file called foo.lua and the require function
> will load it. But if I did only this, calling foo.bar() as above would
> fail, because local foo would be nil, because I did not return anything
> from the implementation. In order to get foo.lua to work I would have to
> do this:
>
>      local package = package
>      module "foo"
>      function bar() ... end
>      return package.loaded.foo
>

     No. All globals declared in the module will be put in the module
table, which will be returned by require().

--
-alex
http://www.ventonegro.org/