lua-users home
lua-l archive

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

How about duplicating _G as the first call you make after instantiating your lua_State (perhaps also nillifying debug and other calls/libs you want to remove) and storing this as a 'starter' environment from which new threads can copy and then add new packages? The 'safe' _G should contain all of Lua's default global libs, functions, values etc. minus whatever you didn't load or essentially removed, plus whatever things you wished to add.

On Jul 23, 2006, at 12:22 AM, Stefan Brantschen wrote:

Tomas -

On 22 Jul 2006, at 15:49, Tomas wrote:

local _G = _G

	And qualify all globals in your program: _G.ipairs.

Sure. But again, this way _all_ globals are accessible from inside the module, and I don't see the module's "providers" (and thus the dependencies) clearly specified at the top, as with "package.seeall".

local assert, ipairs, type = assert, iparis, type

	Which could became a long line.

Right :-)

Easiest would be something like (example)

 local string = require "string"
 local table = require "table"
 module(..., package.seebasics)    -- as suggested also by Andre

Thanks and regards
- Stefan