[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Serializing Lua Functions
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Thu, 7 Dec 2006 15:08:18 -0800
That's the thing. The function will definitely have upvalues. How
does one access them?
On 12/7/06, Rici Lake <email@example.com> wrote:
On 7-Dec-06, at 5:51 PM, 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 =
> --params exist elsewhere in script
> function(state, someValues, otherParams)
> 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?
It's easy if the function has no upvalues. Just use string.dump. If the
function has upvalues, you'd have to serialize them, and they might be
arbitrary objects including userdata.
You might or might not want to worry about the function environment.
I'd be inclined to not worry about it, since the remote machine is
likely to want to run the function in a sandbox anyway.