lua-users home
lua-l archive

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


On Tue, May 7, 2013 at 9:27 AM, Coda Highland <chighland@gmail.com> wrote:
stored anywhere -- if you have "local x = function() ... end", the
function creation doesn't even have a name in scope yet.

Well, Lua does do better that we might expect ;)

local function caller_name ()
    return debug.getinfo(2,"n").name
end

local boo = function()
    print(caller_name())
end

local M = {}

function M.foo ()
    print(caller_name())
end

boo()
--> boo
M.foo()
--> foo