String marshal(any x, Int id)
x: The value to marshal
id: The unmarshalling ID
Return a machine readable
String representation of a variable of any type.
The id given must be identical when unmarshalling to provide some protection against accidentally unmarshalling the wrong value.
Marshalling is intended for passing complex data between two separate instances of the same program. The format is not guaranteed to be the same between versions of the standard library. Also note that if you are marshalling closures, the representation may change when you recompile (as the marshalled form of a closure is based on its function id, generated at compile time). Therefore, Kaya will not unmarshal a representation generated by a program with a different function table.
To pass data other than closures between two programs, in a way that will continue to work in different library versions, consider the Pickle module.
a==b does not necessarily imply
marshal(a,i)==marshal(b,i) as the marshalling format includes some internal representation details for the virtual machine that do not affect equality. This is unlikely to be a problem in most cases (and
unmarshal(marshal(a,i),i)==unmarshal(marshal(b,i),i) is always true if