lua-users home
lua-l archive

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

This seems like a question to which the answer should be obvious, but I'm
going to double-check and ask it anyway. I'm wondering if it's possible to
get a reference to a table which is passed to a C function, if that table is
created during the function call with a table constructor, instead of
created ahead of time. Here's an example of what I want to do:

C code snippet:

int somecfunction(lua_State *L)
    char *a_string;
    int table_reference;

    a_string = lua_tostring(L, 1);
    table_reference = lua_getref(L, 1);

Lua code snippet:

x = {1st_number, 2nd_number, 3rd_number}
somecfunction(a_string, x); -- I'm pretty sure this will work
somecfunction(a_string, {1st_number, 2nd_number, 3rd_number}); -- but I'm
not sure about this one.

Will both of the above function calls work as expected? Also, since I'm
asking, is the correct way to force Lua to perform a garbage-collection to
call lua_setgcthreshold() with an argument of zero?