[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: Paul Moore <p.f.moore@...>
- Date: Thu, 7 Jan 2010 23:10:13 +0000
2010/1/7 Petite Abeille <petite.abeille@gmail.com>:
>
> On Jan 7, 2010, at 6:56 PM, Leo Razoumov wrote:
>
>> What would be Lua-5.2 idioms for creating sandboxes and jails?
>
> Perhaps something along these lines?
>
> function Sandbox( anEnvironment, aFunction, ... )
> in anEnvironment do
> aFunction( ... )
> end
> end
>
> function Test( anIndex )
> print( anIndex, _VERSION )
> end
>
> Sandbox( {}, Test, 1 )
> Sandbox( _G, Test, 2 )
>
>> 1, nil
>> 2, Lua 5.2
>
> Just idle speculation though. Need to get used to the idea of loosing get/setfenv first :/
I thought "in" was lexical, so that the names in Test would *not* be
looked up in anEnvironment. You seem to be assuming that "in" uses
dynamic scope.
Paul.
- References:
- Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- 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., Leo Razoumov
- Re: Lua registry, environment, and threads., Petite Abeille