[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Retrieve name of called function ?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 11 Mar 2002 08:51:59 -0300
>Is the function name from the call still somewhere in the lua stack or
>can I somehow else retrieve the function name under which it was called ?
If you register the same C function with different names in Lua, they are
actually different objects in Lua and you can use the debug interface to find
the name it was registered. Try this:
static int F(lua_State *L)
{
lua_Debug ar;
lua_getstack(L,0,&ar);
lua_getinfo(L,"n",&ar);
printf("F called as %s\n",ar.name);
return 0;
}
lua_register(L,"F",F);
lua_register(L,"G",F);
--lhf