lua-users home
lua-l archive

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


FYI...

On my project we've implemented a modified version of require based around a
notion of code packaging. In the case of MacOS X, these are bundles. Every
bundle gets it's own environment that inherits from the global environment.
That way multiple scripts and C code in the same bundle can see each other,
but they don't stomp the rest of the environment.

We've also built an import mechanism in which one issues a call:

    import "name"

This looks up "name" in a dictionary and returns the value that's there if
it already exists and invokes code to go find something to load if it
doesn't. The loaded code then exports one or more named values (generally
tables). This relies on having metadata associated with loadable entities
indicating what names they can supply.

"require" is mostly used as part of loading pieces of an individual module
while "import" is used to invoke the loading of modules.

Mark