lua-users home
lua-l archive

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


Hi!

2010/8/17 Lorenzo Donati <lorenzodonatibz@interfree.it>:
> [...]
>
> Note that it is a rather "verbose" solution, and that's an intended
> trade-off for (hopefully) better encapsulation, less "baggage", and good
> performance (thanks to heavy use of locals), all under an "avoid globals
> like The Plague" approach.
>
> Are there pitfalls/caveats in this approach (under the assumption that the
> debug library is not used to tamper with the "module system")?
> If every module in the system had this structure, would I be safe from side
> effects from other modules/components/scripts (directly or indirectly
> loaded, either with "require" or with "loadXXX" functions)? Am I missing
> something or assuming too much?

I don't think you approach is verbose. Personally, I use the "simply
return a local table from a 'module'" by myself and have not felt the
need to do something more sophisticated yet. I even do without your
"read-only" safety measure, thus my solution is even more basic.

Using Lua as an extension language, the main benefit of this maybe
most basic approach is that it is explainable to inexperienced and
temporary co-workers.

Regards,
Matthias