lua-users home
lua-l archive

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


On Wed, Mar 24, 2010 at 2:06 PM, Ricky Haggett <ricky@honeyslug.com> wrote:
> Also, if I used setfenv to change the environment, aren't I just moving the
> problem? If I then have to add global functions to this same table, how will
> I differentiate them from the level functions when I need to clean up?

You could use the same trick that module('name',package.seeall) uses.
This creates a module and uses setfenv to make it the current
environment, but package.seeall adds a metatable to this table with
__index set to _G so that any unknown values will be looked up
globally.

So, your table will only contain level-specific stuff, and it will
still be able to access global stuff.

steve d.