lua-users home
lua-l archive

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

On 6 June 2010 19:03, Jim Jennings <> wrote:
> On Sun, 30 May 2010 16:21:44 +0100, Matthew Wild <> wrote:
>> - my concern isn't protecting the default environment as
>> you state, but rather allow my re-environmented (I need to use this
>> phrase more) functions to load modules, independent of each other.
>> As it is, when they call require() most module tables end up out of
>> their reach, unless I provide them with an __index on their
>> environment to _G, and then suddenly they aren't so independent from
>> the main program - which isn't what I wanted.
> I needed the same property -- modules that were independent of each
> other and of the main environment.  I wrote a layer that rides on top
> of the Lua module system that provides this property.  It's called
> Darwin, and you can find it at:
> The Darwin module system is completely backwards compatible with
> regular Lua modules.  Existing Lua modules can be used as-is, or you
> can Darwin-ize them by writing a one- or two-line declaration that
> will tell Darwin to put it into its own environment when you load it.

I gave Darwin a look over. It certainly seems to have the right
principles, and you've clearly put a lot of thought and effort into it

Just a couple of questions... it looks like I have to specify the
exported functions for any module I require, is this correct?

Also how does it prevent C modules from modifying the main
environment? (Does it even work with C modules?)