lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks a lot for your answers!!! It helps me a lot.

Nicolas


On Fri, Mar 28, 2008 at 2:48 AM, Patrick Donnelly <batrick.donnelly@gmail.com> wrote:
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