[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: can a C extension function determine its name?
- From: "Lythoner LY" <lythoner@...>
- Date: Mon, 1 Oct 2007 14:13:16 +0530
Gerald,
I couldn't get anything so far with your example :-(. FuncTables looks like advanced concepts which I haven't encounter before. Anyway thanks for link and I will try my best to learn, try the solution and post my experience back. If anybody have some direct hint/example, it would help me (newbie).
Thanks
Krish
On 10/1/07, Gerald Franz <gerald.franz@googlemail.com> wrote:
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