lua-users home
lua-l archive

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

Oops, yeah sorry about the spelling.  I ment marshal actually.  I used the spelling that the gtk marshaler uses, I used marshall origionaly in my code.  I think both may be right.

Actually I think in my implementation I do not care too much about shared upvalues, someone else may need that, I don't know.  I was hoping to avoid using the debug library if at all possible.  Ill have to look at how Pluto does things when luaforge comes back up.

Basicly whats important to me is the ability to send arbitrary functions, an example of use would be to send a function that gets executed in the other process to decrypt some data sent.  In this case the other process need not know anything about how to decrypt the data, it just runs the function. And of course to send LUA data itself (tables, numbers, strings, whatever, it should not matter the type, with the exception of userdata, and probably threads of course).


Lua list <> on Friday, September 15, 2006 at 10:13 AM +0000 wrote:
Michael Panetta wrote:

> But this does not work, because when lua_dump creates the
> chunk, the upvalue gets lost.  Does anyone know of a way
> to do something almost as simple (I would like to make it
> so that all the marshalling is done in lua, not C) to get
> the data through?

You can use debug.getupvalue to get the values of the
upvalues from the original function, and then save them to
be reset with debug.setupvalue after reloading the dumped
chunk.  This would not honor shared upvalues -- two
functions that share an upvalue would end up having two
independent upvalues.

(It's basically impossible to honor shared upvalues and
still implement this in pure Lua: the only way to even tell
whether two upvalues are the same variable is to set one and
see if the other changes, and the only way [that I can think
of] to get two chunks to act like their upvalues are shared
would be some nasty hack that checks whether the upvalues'
values have been changed after every instruction.)

The Pluto library (which does its heavy lifting in C, and
which you can check out once LuaForge is back up) does this
in full generality, honoring shared upvalues.

By the way, "marshall" is the correct spelling (you used
"martial" a couple times).