caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Classes and marshaling
@ 2002-02-04 15:58 Frederic Tronel
  2002-02-05 12:32 ` Frederic Tronel
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Tronel @ 2002-02-04 15:58 UTC (permalink / raw)
  To: caml-list

Is it possible to serialize an object ??
In the toplevel:

        Objective Caml version 3.04

#  open Marshal ;;
#  class a = object end ;;
class a : object  end
#  to_string (new a) [] ;;
Exception: Invalid_argument "output_value: object value".
#

Best regards,


Frederic Tronel.
-------------------
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Classes and marshaling
  2002-02-04 15:58 [Caml-list] Classes and marshaling Frederic Tronel
@ 2002-02-05 12:32 ` Frederic Tronel
  2002-02-06 18:36   ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Tronel @ 2002-02-05 12:32 UTC (permalink / raw)
  To: caml-list

Frederic Tronel wrote:
> 
> Is it possible to serialize an object ??
> In the toplevel:
> 
>         Objective Caml version 3.04
> 
> #  open Marshal ;;
> #  class a = object end ;;
> class a : object  end
> #  to_string (new a) [] ;;
> Exception: Invalid_argument "output_value: object value".
> #
> 
> Best regards,
> 
> Frederic Tronel.
> -------------------
> 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

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). 

Is there any chance to see object serialization being implemented in the
near future ??
By the way I did not find any reference about this problem in the
documentation
(in the book by chailloux, manoury and pagano, they mention that
abstract
types cannot be serialized, but it seems they do not mention objects).

Best regards,

Frederic Tronel.
-------------------
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Classes and marshaling
  2002-02-05 12:32 ` Frederic Tronel
@ 2002-02-06 18:36   ` Xavier Leroy
  0 siblings, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 2002-02-06 18:36 UTC (permalink / raw)
  To: Frederic Tronel; +Cc: caml-list

> 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
breath.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-02-06 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-04 15:58 [Caml-list] Classes and marshaling Frederic Tronel
2002-02-05 12:32 ` Frederic Tronel
2002-02-06 18:36   ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).