lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I wonder if there is a more convenient and elegant way to do this.

On 12/7/06, Hakki Dogusan <> wrote:

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
             return m, mi

         return maximum({8,10,23,12,5})


     local rc = S:call("testapp", "test3")
     errreport(S, rc)

     local m  = S:result(0)
     local mi = S:result(1)
     print("m:" .. m .. " mi:" .. mi)


You can get dsas from

Hakki Dogusan

Ivan Smirnov

Department of Math and Stat Sciences
622 CAB
University of Alberta
Edmonton, AB, Canada
T6G 2G1,