ICI Modules: serialisation

Modules by name : by type


The serialisation module extends ICI with two new functions, save() and restore(), to write and read arbitrary objects to and from files. Any base ICI object type, other than files, may be serialised, including all scalar and aggregate types, pointers, memory objects, functions, method objects and native-code functions ("cfuncs"). Serialisation supports full ICI object semantics including both atomic and self-referential objects and uses a well-defined protocol which operates across machine architectures and is especially suited to use over network connections.

Other than the "standard" uses for serialisation, storing data in files so it is easily read and written, the ability to serialise functions opens up opportunities for far more complex usage. Agent-like systems that rely upon mobile programs are greatly simplified as are database search operations and similar situations where transferring a program, or function, and its results are less than the cost of transferring the input data to the code.


The serialisation module actually consists of two separate modules each of which exports itself as a single function object.

The save module implements the write-side of the serialisation protocol while the restore module implements the read-side. The functions have the following usage,

The specifics of the protocol are not yet documented. The source code is the current specification. Other than a number of small bug fixes and adaptions to language changes the protocol has not changed in many years.


A data structure used in many programs is the array of records, i.e, a database. In ICI this is typically represented as an array of struct objects. Each struct storing the data to be stored. The array giving some order to the records and collecting them underneath a single object. To save or read this structure to and from disk typically requires writing a loop to iterate over the records and calling some record specific routine to write the data. Serialisation makes things a lot easier.

Say our data structure is called database, the following code is sufficient to save it to disk,

	file := fopen(filename, "w");
	save(database, file);
Reading is just as easy,
	file := fopen(filename;
	database = restore(file);

More examples...