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:26 AM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> On 7/05/2013, at 7:02 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>
>> How hard is it for a running function to find out the name of the
>> function from which it was called?
>
>> I've snooped around with debug.getlocal and debug.getinfo and
>> I can't find it.
>
>
> Does this help?
>
> $ lua
> Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
>> function a() print(debug.getinfo(2, "n").name) end
>> function b() a() end
>> b()
> b
>> c = b
>> b = nil
>> c()
> c
>
>

Seems I spoke too soon!

/s/ Adam