lua-users home
lua-l archive

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

On Tue, May 7, 2013 at 12:02 AM, Dirk Laurie <> wrote:
> How hard is it for a running function to find out the name of the
> function from which it was called?

Quite difficult, actually! Remember, Lua functions don't actually HAVE
names. They're just values that happen to be callable, and they can be
stored anywhere -- if you have "local x = function() ... end", the
function creation doesn't even have a name in scope yet.

The best you could do would be to guess at what name was used at the
invocation point, but I don't think Lua offers introspection at that
level without digging into the bytecode.

/s/ Adam