caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* marshalling objects
@ 2005-11-11  4:54 Pietro Abate
  2005-11-11  5:21 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 5+ messages in thread
From: Pietro Abate @ 2005-11-11  4:54 UTC (permalink / raw)
  To: ocaml ml

Hi all,

It's not clear to me if it is possible or not to marshall objects ? From
my tests it is not the case (output_value: abstract value (outside
heap).). Am I missing something ? What is common practice to send
objects across the wire ?

thanks,
p

--------- ex.ml

class node = object val d = 1 end ;;

let l =
    try
        let a = (new node) in
        let s = (Marshal.to_string a [])
        in print_endline "Success"; (Marshal.from_string s 0 : node)
    with Invalid_argument s -> print_endline ("Failed "^s) ; (new node)
;;

let l =
    try
        let a = (new node) in
        let s = (Marshal.to_string a [Marshal.Closures])
        in print_endline "Success"; (Marshal.from_string s 0 : node)
    with Invalid_argument s -> print_endline ("Failed "^s) ; (new node)
;;

let l =
    try
        let a = (new node) in
        let s = (Marshal.to_string a [Marshal.No_sharing])
        in print_endline "Success"; (Marshal.from_string s 0 : node)
    with Invalid_argument s -> print_endline ("Failed "^s) ; (new node)
;;

let l =
    try
        let a = (new node) in
        let s = (Marshal.to_string a [Marshal.No_sharing;Marshal.Closures])
        in print_endline "Success"; (Marshal.from_string s 0 : node)
    with Invalid_argument s -> print_endline ("Failed "^s) ; (new node)
;;


-- 
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++ 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html


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

* Re: [Caml-list] marshalling objects
  2005-11-11  4:54 marshalling objects Pietro Abate
@ 2005-11-11  5:21 ` Jacques Garrigue
  2005-11-14  9:49   ` sejourne_kevin
  0 siblings, 1 reply; 5+ messages in thread
From: Jacques Garrigue @ 2005-11-11  5:21 UTC (permalink / raw)
  To: Pietro.Abate; +Cc: caml-list

From: Pietro Abate <Pietro.Abate@anu.edu.au>

> It's not clear to me if it is possible or not to marshall objects ? From
> my tests it is not the case (output_value: abstract value (outside
> heap).). Am I missing something ? What is common practice to send
> objects across the wire ?

It is possible, but there was a bug in 3.08.
In 3.09, you can marshal an object with
   Marshal.to_string obj [Marshal.Closures]
Note that this means that the method table is really sent, as an array
of closures, which is possibly very innefficient, and also means that
the program on the other side must be the same one.

Jacques Garrigue


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

* Re: [Caml-list] marshalling objects
  2005-11-11  5:21 ` [Caml-list] " Jacques Garrigue
@ 2005-11-14  9:49   ` sejourne_kevin
  2005-11-14 10:01     ` Jacques Garrigue
  0 siblings, 1 reply; 5+ messages in thread
From: sejourne_kevin @ 2005-11-14  9:49 UTC (permalink / raw)
  To: caml-list

Jacques Garrigue a écrit :
> Note that this means that the method table is really sent, as an array
> of closures, which is possibly very innefficient, and also means that
> the program on the other side must be the same one.

Exactly the same one or just all classes ?
I think this could be in the manual of module Marshal.


Kévin.

	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com


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

* Re: [Caml-list] marshalling objects
  2005-11-14  9:49   ` sejourne_kevin
@ 2005-11-14 10:01     ` Jacques Garrigue
  0 siblings, 0 replies; 5+ messages in thread
From: Jacques Garrigue @ 2005-11-14 10:01 UTC (permalink / raw)
  To: sejourne_kevin; +Cc: caml-list

From: sejourne_kevin <sejourne_kevin@yahoo.fr>
> Jacques Garrigue a écrit :
> > Note that this means that the method table is really sent, as an array
> > of closures, which is possibly very innefficient, and also means that
> > the program on the other side must be the same one.
> 
> Exactly the same one or just all classes ?
> I think this could be in the manual of module Marshal.

Actually it's just a consequence of the internal representation of
classes, which is described in the C interface section.
That is, each object contains an array with all its methods, which are
function closures.
This is the reason you need the flag for closures.
And the condition with closures is quite explicit: this must be
exactly the same program. I also expect that, for native code, it must
be the same architecture.

Jacques Garrigue


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

* marshalling objects
@ 2008-04-25 20:42 Jacques Le Normand
  0 siblings, 0 replies; 5+ messages in thread
From: Jacques Le Normand @ 2008-04-25 20:42 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

hello caml list,
if I marshal an object of class c and I write the result in a file foo.txt
and, later on, I add methods to c, can I read the object in foo.txt and call
the new methods on the object?
cheers
--Jacques

[-- Attachment #2: Type: text/html, Size: 231 bytes --]

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

end of thread, other threads:[~2008-04-25 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-11  4:54 marshalling objects Pietro Abate
2005-11-11  5:21 ` [Caml-list] " Jacques Garrigue
2005-11-14  9:49   ` sejourne_kevin
2005-11-14 10:01     ` Jacques Garrigue
2008-04-25 20:42 Jacques Le Normand

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