I have a table on the Lua stack. How can I push a function on the stack that returns this table? -
using c
api, have pushed table on lua stack. how can push function on stack returns table?
the closest can find lua_pushcclosure
, pushes lua_cfunction
on stack, not real lua function, , not acceptable in case because want use setfenv
later, works real lua functions.
regards
well, obvious. since must "real lua function", must create real lua function returns table.
something this:
local tbl = ... return function() return tbl end
this lua chunk that, when executed, return function returns first parameter original chunk called with.
so use lual_loadstring
load string. call resulting chuck table; return value function desire.
that being said, question makes no sense. setfenv
not accomplish of value here. setting environment of function returns local table not affect stored within table.
Comments
Post a Comment