lua-users home
lua-l archive

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


On Oct 18, 2011, at 12:20 AM, Sean Conner wrote:

>  Assume for a moment there are several other modules that require this
> module.  Without a global namespace, each module will get their own copy of
> this module, which would mean wasted space as there are multiple copies of
> this data (and that paths table could be pretty big ... [1])

require will only load a module once. Subsequent uses of require will just return this same module.

The globals issue has to do with whether a change is made to the globals table. You can still refer to your module as org.conman.dns and require will do the right thing.

The danger with changing the globals table is that code might start referencing org.conman.dns without doing an appropriate require and would just happen to work because some other code that ran before it did the require. And then it later breaks because the code execution sequence changes somewhere and you can't figure out why code that used to work just fine no longer works.

Mark