[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Serializing Lua Functions
- From: Hakki Dogusan <dogusanh@...>
- Date: Fri, 08 Dec 2006 01:13:11 +0200
Hi,
Wesley Smith wrote:
Out of curiosity, has anyone made an attemp to serialize Lua functions
which could potentially be streamed across a network? What I'm
looking for is something like this...
local streamThisFunction =
function()
--params exist elsewhere in script
function(state, someValues, otherParams)
end
SendToNetwork(streamThisFunction)
When streamThisFunction is received by another computer, they are able
to call streamThisFunction() and have it behave as if it were called
on the original sender's machine.
If no one has done this, what might be invloved in doing it?
thanks,
wes
Not exactly streaming, but I did something like in dsas.
I'm sending function as string to server to execute.
There is this code in tests.lua:
function test_testapp_test3(S)
print("------- send function to execute (danger!) ------")
local ss = [[
-- from PIL p:33
function maximum(a)
local mi = 1 -- maximum index
local m = a[mi] -- maximum value
for i,val in ipairs(a) do
if val > m then
mi = i
m = val
end
end
return m, mi
end
return maximum({8,10,23,12,5})
]]
S:push(ss)
local rc = S:call("testapp", "test3")
errreport(S, rc)
local m = S:result(0)
local mi = S:result(1)
print("m:" .. m .. " mi:" .. mi)
print("passed...")
end
You can get dsas from http://www.dynaset.org/dogusanh
--
Regards,
Hakki Dogusan