lua-users home
lua-l archive

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


On Tue, Oct 23, 2012 at 7:06 AM, Elias Barrionovo
<elias.tandel@gmail.com> wrote:
> On Oct 23, 2012 4:29 AM, "Rena" <hyperhacker@gmail.com> wrote:
>> "wouldn't it
>> be interesting if we could access local variables by table indexing
>> syntax".
>
> It would indeed. Another pro is the possibility of docstrings.
>
> But it does raise some concerns about security and sandboxing: if locals and
> upvalues are accessible, how to wrap functions and properly create
> sandboxes?
>
> If this behavior were to be implemented, there should also be a way to
> signal the interpreter that certain locals / upvalues should not be exposed.
> In fact, unexposed values should be the default for security and
> compatibility reasons.
>
> One way is to add a new reserved word such as "exported", that would behave
> just like "local", except for the fact that the value would them be
> accessible via indexing

Well, you could always set a metatable for the function that traps
__index and __newindex the same as you would for a table...

-- 
Sent from my Game Boy.