Reputation: 131
Not using load, i would have this source:
function dosearch(t)
t:search()
end
and call it with
dosearch(my_search_t)
However, i want to use load to evaluate a string with the above code inside.
codestr = "t:search()"
searchfunc = load(codestr)
And finally call it:
function callsearch(t)
-- How to use debug.setupvalue to pass t?
searchfunc()
end
How do i use debug.setupvalue to pass t?
Upvotes: 0
Views: 98
Reputation: 974
function dosearch(t)
t:search()
end
is equivalent to
dosearch = load [[
local t = ...
t:search()
]]
Upvotes: 2