lua-users home
lua-l archive

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


That may be possible, but the function is sometimes passed in a variable and so it isn't hardcoded. We have a code preprocessor and it's theoretically possible, but we would have to detect the difference between by value and by name intentions, find the function the variable refers to and then replace it with a string. Messy.  It looks like we should put the effort into finding the function on the way into lua and then using that as a key into the registry or something as this will perform very well at runtime. 

Or, couldn't I just create a string of the function name as a closure to the function?

Brett

----- Original Message ----- 
From: "Kevin Baca" <lualist@aidiastudios.com>
To: "'Lua list'" <lua@bazar2.conectiva.com.br>
Sent: Saturday, March 06, 2004 12:45 AM
Subject: RE: function name


> How about passing the name of the function instead?
> 
> function Fooey()
>      SetSomeValueInTheCHost("Foo")
> end
> 
> -Kevin
> 
> > 
> > Ashwin,
> > Thanks for your note.  I read the debug stuff before posting 
> > but assumed it wasn't meant for runtime use. I guess I should 
> > be more specific.  I need to retrieve a few thousand 
> > functions names per second. Under the debug section it says 
> > "The lua_getinfo function checks how the function was called 
> > or whether it is the value of a global variable to find a 
> > suitable name. If it cannot find a name, then name is set to 
> > NULL."  So if I have:
> > 
> > function Foo()
> >     -- some code here
> > end
> > 
> > And then...
> > 
> > function Fooey()
> >     SetSomeValueInTheCHost(Foo)
> > end
> > 
> > And my C host has...
> > 
> > int SetSomeValueInTheCHost(lua_State *luaStatePtr)
> > {
> >     // the first value on the lua stack is a function, how 
> > can I get the name fast here?
> >     // candidates include getfuncname or getobjname?
> > }
> > 
> > With the decalration as per above, would getfuncname or 
> > getobjname retrieve anything useful? Is there a better/faster way?
> > 
> > Thanks,
> > Brett
> > 
> > ----- Original Message ----- 
> > From: "Ashwin Hirschi" <deery@operamail.com>
> > To: "Lua list" <lua@bazar2.conectiva.com.br>
> > Sent: Friday, March 05, 2004 10:16 AM
> > Subject: Re: function name
> > 
> > 
> > > 
> > > > Is there anyway to get, find or resolve the string name 
> > of a function on the stack?
> > > 
> > > Have a look at Lua's "debug interface":
> > > 
> > > http://www.lua.org/manual/5.0/manual.html#4
> > > 
> > > Ashwin.
> > > -- 
> > > no signature is a signature
> >