lua-users home
lua-l archive

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

> [...]
> which resulted in "Name of function: lua_func". After upgrading to Lua 
> 5.1.2 it doesn't seem to work that way anymore. I tried to use 
> lua_getinfo() in several different ways and also tried the following:
> [...]

Functions in Lua have no names, so all code to get "names" for them is
based on heuristics. In earlier versions, Lua traversed the global table
trying to find a global variable containing the function and then used
that global name as the function name. In Lua 5.1, with the new module
system, that traversal became too specific, as many (most?) functions 
now do not live in the global space, so we removed it from the core.

If you want, you can write the traversal in your code, using lua_next.
It is straightforward (but with limited results, as noted above). (Maybe
we will add some enhanced version of this traversal in Lua 5.2, which
looks inside global tables too...)

-- Roberto