lua-users home
lua-l archive

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





On Tue, Jan 14, 2014 at 9:18 AM, Fabien <fleutot+lua@gmail.com> wrote:
Also, if you want something low-level, you can look at Mihini's serialization format: http://git.eclipse.org/c/mihini/org.eclipse.mihini.git/tree/luafwk/luatobin/luatobin.c. It's pretty much self-sufficient (just a common header to handle endianness IIRC). It's designed for storage and RPC in embedded contexts.


This is very helpful. It's most of what I hoped for insofar as table serialization goes.
 
It handles shared/circular references in tables, and functions without upvalues. Not userdata. As mentioned by someone else, You generally don't want to send around stuff full of metadata / upvalues / userdata anyway: they're normally part of the infrastructure exchanging data, not part of the data exchanged. And they often embed behaviors featuring a lot of side effect: you don't want those traveling across the network without a second though.


Right. This makes good sense. There are two issues: what to serialize and what to generalize.

It seems reasonable to avoid serializing behavior at the same time one is serializing data. So, you might need to state that the object behaviors are on both ends, or provide a method to declare behaviors and associate them with specific messages.

Perhaps it is that second part that is not generalizable, outside of a high-level library. I think I'm imagining an export library with the concept of a foreign registry. Something like:

1: You register a message type, complete with methods, etc.
2: You send messages that match those types.
3: The registered functions are in charge of deserializing and imbuing the incoming message with behaviors, as necessary.

Part of my anxiety is in not having much experience serializing data. I think I need to just "try some stuff". The luatobin code looks like a good start.

-Andrew