lua-users home
lua-l archive

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


 Using LOOP, this is very simple.. :)

local StringStream = require "loop.serial.StringStream"


function encode( _message )
    local stream = StringStream()
    stream:put( _message )
    return stream
end

function decode( _data )
    local stream = StringStream{ data = tostring( _data ) }
    local potentialmessage = stream:get()
    return potentialmessage
end


On 2010-10-02 12:20, Ico wrote:

* On 2010-10-02 Sean Conner<sean@conman.org>  wrote  :

   Okay, now I'm curious---how does one *get* a compiled Lua table?  I can
see how to get a Lua function (in fact, I'm doing that now, only between
separate Lua instances and not over a network connection) but a table?
What about compiling a function returning the table:

   function foo()
     return { "one", "two", "three" }
   end

   local compiled = string.dump(foo)

and to retrieve the table do a loadstring:

   ti loadstring(compiled)()