[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Gets function name from the stack
- From: "Nicolas ANTONIAZZI" <nicolas.antoniazzi@...>
- Date: Fri, 28 Mar 2008 13:36:59 +0100
Thanks a lot for your answers!!! It helps me a lot.
On Fri, Mar 28, 2008 at 2:48 AM, Patrick Donnelly <firstname.lastname@example.org
If you want the name the function was called with, here's how Lua gets
it (and how you get those really nice argument error messages in C):
/* UNTESTED */
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
ar.name = "?"; /* Some default ? */
lua_getinfo(L, "n", &ar);
if (ar.name == NULL)
ar.name = "?"; /* <-- PUT DEFAULT HERE */
I think this is slow though? So perhaps you may want to avoid it
unless it is really necessary...
Hope that helps,
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."