6.9 Object Serialization (original) (raw)

6.9 Object Serialization🔗

(define-serializable-class* class-id superclass-expr
(interface-expr ...)
class-clause ...)

Binds class-id to a class, where superclass-expr, the interface-exprs, and the class-clauses are as inclass*.

This form can only be used at the top level, either within a module or outside. The class-id identifier is bound to the new class, and deserialize-info:class-id is also defined; if the definition is within a module, then the latter is provided from a deserialize-info submodule via module+.

Serialization for the class works in one of two ways:

In the second case, a serializable subclass can implementexternalizable<%>, in which case the externalizemethod is responsible for all serialization (i.e., automatic serialization is lost for instances of the subclass). In the first case, all serializable subclasses implementexternalizable<%>, since a subclass implements all of the interfaces of its parent class.

In either case, if an object is an immediate instance of a subclass (that is not itself serializable), the object is serialized as if it was an immediate instance of the serializable class. In particular, overriding declarations of the externalize method are ignored for instances of non-serializable subclasses.

(define-serializable-class class-id superclass-expr
class-clause ...)

Like define-serializable-class*, but without interface expressions (analogous to class).

The externalizable<%> interface includes only theexternalize and internalize methods. Seedefine-serializable-class* for more information.