[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Gets function name from the stack
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Thu, 27 Mar 2008 19:48:46 -0600
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 */
lua_Debug ar;
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
ar.name = "?"; /* Some default ? */
else
{
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,
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant