[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: David Manura <dm.lua@...>
- Date: Sat, 9 Jan 2010 10:37:39 -0500
On Sat, Jan 9, 2010 at 6:29 AM, steve donovan wrote:
> However, (and this is a nasty) there are some tricks you cannot do
> with debug.setfenv.
>
> Consider this implementation of David Manura's 'module environment ~=
> module table' idea: [package.clean] ....
http://lua-users.org/wiki/ModuleDefinition
> debug.setfenv(3,env) .....
> ../lua: ./closed.lua:12: 'setfenv' cannot change environment of given object
In 5.1, setfenv can take a stack level number but debug.setfenv can
not. debug.setfenv can take a userdata but setfenv could not. One is
not a subset of the other. Now, in 5.1 you can alternately obtain the
function at a given stack level number like debug.getinfo(3, 'f').func
and then call setfenv or debug.setenv on it to achieve the same effect
to setenv with a stack level number. In Lua 5.2.0-work1, this
functionality is maintained, though in the debug library.
- References:
- Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Enrico Colombini
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Edgar Toernig
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., Leo Razoumov
- Re: Lua registry, environment, and threads., steve donovan