lua-users home
lua-l archive

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


> > 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' )
> 
> ...
> 
> This is a clear regression. 

In my view this is clear progress.

Modules do not interfere with each other: module 1 does not change the
environment for module 2 (as happened by mistake in your example),
module 2 does not see locals declared in module 1, etc. Each module is
sintactically distinct, with a clear boundary around each. They are
much more self contained.

-- Roberto