[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Not getting the function name using the Debug Library in Lua 5.1
- From: Mike Pall <mikelu-0801@...>
- Date: Mon, 28 Jan 2008 13:09:30 +0100
E. Wing wrote:
> Since these were only triggered on error conditions, debug.getinfo
> would only be called in limited situations (basically for the exact
> purpose of debugging) so performance was not an issue.
To get the Lua 5.0 behaviour use this:
local function findglobal(f)
for k,v in pairs(_G) do
if v == f then return k end
end
end
...
local info = debug.getinfo(level, "nSlf")
local name = info.name or findglobal(info.func)
...
print(name)
--Mike