lua-users home
lua-l archive

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


Hello, People

Under the risk of sounding stupid, just a curiosity: is there any reason I should not be able to access the function arguments when I access the function environment via getfenv() ?

My guess would be that this is some colateral effect of the paremeters being local.

I have no doubt that the argument variables should be local - so they won't collide with global environment. But when I am accessing my caller's environment from another function, the lack of access to his arguments looks kinda strange to me.

code:
function service(arg1, arg2)
    x = 1
    y = 2
    local z = 3
    doSomeReallyIntuitiveStuff('anyDebug')
end

function doSomeReallyIntuitiveStuff(msg)
    env = getfenv(2)
    local z = env.x + env.y  -- that´s kind of useful
    -- although env.z is not available (ok)
    -- env.arg1 and
env.arg2 might also be useful here
end


--
Luís Eduardo Jason Santos
Coordenador Técnico
IT Quality Systems
lsantos@itquality.com.br
[21]2242-7959 ramal 219