[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What is the name of the calling function?
- From: Coda Highland <chighland@...>
- Date: Tue, 7 May 2013 00:27:48 -0700
On Tue, May 7, 2013 at 12:02 AM, Dirk Laurie <email@example.com> 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.