lua-users home
lua-l archive

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


On Tue, Jul 28, 2015 at 09:44:46AM +0000, Laurent FAILLIE wrote:
> Hello,
> I'm looking for a way to find out a function from it's name.
> I understood from the documentation that function are handled as "normal" object, so with my test code, I'm expecting to find it in global variable table.So I'm calling lua_getglobal() on the function name but it fails and returns a NIL.

Functions, much like other values such as 42, "spatula" and false do not
have names, they are values.

A function may have any number of variables that have names assoicated
with it; including zero.

The best you can hope for is to spider the entire environment looking
for a variable that contains the same function you're looking for and
also hope that it's a usefully named one.

B.