English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Classes and marshaling
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-02-06 (18:36)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Classes and marshaling
> Is it possible to serialize an object ??

Currently not.

> After having taken a look at the source code (byterun/extern.c), it
> seems that caml value tagged with Object_tag (that is object) are
> simply ignored (an exception is raised).

They are not ignored, but rejected :-)

> Is there any chance to see object serialization being implemented in
> the near future ??

Object serialization, like function serialization, is quite a
challenge.  One can either send the code for the object's methods, so
that it can be read back anywhere -- but OCaml's code is not
relocatable enough to allow this; or one send the object's instance
variables only, and add various mechanisms to ensure that the method
code at the receiving end is compatible with that at the sender -- but
no such really good mechanism exist (witness Java's serialization).

So, we're thinking about it, especially in the context of JoCaml (a
distributed programming language based on Caml), but don't hold your

In the meantime, I'd recommend either serializing objects "by hand"
(via methods that write the object's state), or converting between your
objects and a pure datatype that you can then read and write
efficiently with output_value and input_value.

- Xavier Leroy
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr