> I am trying to find out where "add" function is stored. Since it is defined local it was not there in _ENV and _G. I also cannot find it in the upvalues. Where is the function?

It's not an upvalue, it's a regular local value, so you'd need to use

`debug.getlocal` instead (iterate over values and find the one with

the name you are looking for). Something like this should work:

i = 1

while true do

local name, value = debug.getlocal(1, i)

if not name then break end

print(name, value)

i = i + 1

end

Paul.

On Sat, Mar 3, 2018 at 5:22 PM, Milind Gupta <

[hidden email]> wrote:

> Hi,

> I have the following code snippet:

> ---------------------------------------------------

>

> local function add(a,b)

> return a + b

> end

>

> print(_ENV["add"],_G["add"],add)

>

> for k,v in pairs(_ENV) do

> print(k,v)

> end

> print("-------------------")

>

>

> print(debug.getupvalue(debug.getinfo(1).func,1))

> ------------------------------------------------------

>

> I am trying to find out where "add" function is stored. Since it is defined

> local it was not there in _ENV and _G. I also cannot find it in the

> upvalues. Where is the function?

>

> Thanks,

> Milind