[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Calling Lua function from C
- From: Max Ischenko <max@...>
- Date: Sat, 21 Jun 2003 12:34:36 +0300
Peter Shook wrote:
> >But then another issue arises -- for each function returned
> >I have to have a duplicate entry in the Registry. While I'm going to
> >have hundreds of such refs this could become a problem. May be I just
> >could setup some hash table in Lua with integer indicies and return it
> >instead of function...
> I'm not sure I follow. You have a lot of functions in Lua, that you
> want to call from C later on, but you don't need to give them names?
> So you want to call foobar from C, store the table of functions
> somewhere, then later on, call each of the functions in a loop or
> something? Basically the following in C ?
Actually, use case is this: given a Lua expr. I'd like to compile it
(into anonymous function) and return pointer to it back to C. Then I'm
going to evaluate that expr (function) many times with different args.
There could be hundreds of such expr. around.
As it turned out, I can't easily store a pointer to Lua function in C,
I'm thinking about returning something more simple (like integer) to
escape the need for luaL_ref/luaL_unref and setup a hash table in Lua
with integer<->function mapping.