Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
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:  FAQ:
To unsubscribe, mail  Archives: