lua-users home
lua-l archive

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


On Mon, Aug 26, 2013 at 8:00 AM, Rafis DoctorInfo
<rafisganeyev@gmail.com> wrote:
> 2013/8/24 Thijs Schreijer <thijs@thijsschreijer.nl>
> I thought about run-time checks only, compiler time checks for such task
> looks odd to me (it can't handle loadstring/loadfile). In case of global
> scope I can check it through strict.lua
> (http://lua-users.org/wiki/DetectingUndefinedVariables). But in case of
> local scope I can't manage it. It would be nice to have some function to
> enable such check on run-time debug.strict_locals(true). Is it possible to
> write such function in C using Lua API ABI or do I need to modify Lua core?

I would argue that loadstring/loadfile wouldn't apply ANYWAY, as they
create new scopes -- if a variable declared inside loadstring/loadfile
shadows something in the parent scope, it's actually DESIRABLE to
permit it.

I think it makes perfect sense to handle such a check at compile-time,
since the compiler can easily identify when the same name is used a
second time in the same scope -- it has to map names to stack slots,
after all.

/s/ Adam