lua-users home
lua-l archive

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


Thank you Jerome,
that's a very good hint, I will play a little bit with it and hopefully come up with something similar to my original intention.
Regards,
Gerald

In Lua a function has no name, so it cannot determine it. However it's
very easy to create new functions dynamically in Lua, so you can use
this to do what you're trying to achieve.

Suppose your C function is a global function called f, and that
receives as first parameter it's name, and subsequent parameters are
dependent on the name.

local m = {}
setmetatable(m, {__index=function(t,funcname)
    return function(...)
        return f(funcname, ...)
    end
end
 

[1] http://lua-users.org/wiki/FuncTables