[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: can a C extension function determine its name?
- From: "Gerald Franz" <gerald.franz@...>
- Date: Mon, 1 Oct 2007 10:17:24 +0200
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