[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: protect a set in c (non-existing elements)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 14 Feb 2014 22:01:34 +0200
2014-02-14 21:46 GMT+02:00 Thijs Schreijer <thijs@thijsschreijer.nl>:
> Tested it and this code (modified from the example by Dirk);
>
> char *lua_init_code =
> "local params={...} "
> "for k in pairs(params) do print(k,v) end "
> ;
>
> int testfunc (lua_State *L) {
> luaL_loadstring(L, lua_init_code);
> lua_pushstring(L, "parameter 1");
> lua_pushinteger(L, 2);
> lua_call(L, 2, 0); // 2 args, 0 results
> return 1;
> }
>
> Prints
> 1 nil
> 2 nil
>
> So the function returned by luaL_loadstring has a signature 'function my_chunk()' and doesn't define the vararg. Too bad...
> Any clues to why not? Would make sense to me that it would define the vararg.
Change line 3 of lua_init_code to:
"for k,v in pairs(params) do print(k,v) end "
Reeds meer dan tien uren aan 't werken? Tijd voor een pintje, niet?
Dirk