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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -