lua-users home
lua-l archive

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

--- In, Luiz Henrique de Figueiredo <lhf@t...> 
> For a Lua 5.0 solution see test/readonly.lua in the alpha or beta 

This seems to work nicely, but only at the level at which setglobals
() is called. For instance, say you have the following:

-- this code is extracted from test/readonly.lua
local f=function (t,i) error("cannot redefine global variable 
`"..i.."'",2) end
local g={}
local G=getglobals()

-- test function
function foo() x = 1 end

foo()  -- no error
y = 1  -- error

When foo() is called, no error occurs. Is there a way to propagate 
"read-only globals" to all function calls (at any level 
of nesting) following the setglobals() call?