lua-users home
lua-l archive

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

Max Ischenko 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...

Hi Max,

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?

function foobar()
  return {
    assert(loadstring'return 2+3');
    function() return 4+5 end;
    function() print(whatever) end;

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 ?

  t = foobar()
  for n,v in t do print( v() ) end

- Peter Shook