lua-users home
lua-l archive

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


On Sun, Jul 11, 2010 at 4:20 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
> Do you think it would be an issue if scripts still could create and
> update a variable such as http.socket?  That would be a non-global
> access at the bytecode level, but it still would introduce coupling.
> Should modules be read-only from a user's point of view?

I suspect most globals in Lua programs are precisely these
module-scope variables. They are of course just as global in effect as
any other.

They can be made into pseudo-variables (essentially static properties
of the module), so that the variable socket.http is actually the
getter and setter part socket.get_http() and socket.set_http()) and
then they can be backed by thread-local storage)

Modules are 'open' to further modification, being dynamic constructs.
It would be useful to be able to declare them as 'sealed'  (it
wouldn't be difficult to define 'package.sealed' as a modifier for
module())

steve d.