[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Serializing Lua Functions
- From: "Ivan Smirnov" <i.s.smirnov@...>
- Date: Thu, 7 Dec 2006 16:15:33 -0700
I wonder if there is a more convenient and elegant way to do this.
On 12/7/06, Hakki Dogusan <dogusanh@tr.net> wrote:
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
--
Regards,
Ivan Smirnov
Department of Math and Stat Sciences
622 CAB
University of Alberta
Edmonton, AB, Canada
T6G 2G1
ismirnov@math.ualberta.ca, i.s.smirnov@gmail.com