caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* marshalling objects
@ 2008-04-25 20:42 Jacques Le Normand
  2008-04-26  6:45 ` [Caml-list] " Basile STARYNKEVITCH
  2008-04-26  7:42 ` Richard Jones
  0 siblings, 2 replies; 4+ 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] 4+ messages in thread

* Re: [Caml-list] marshalling objects
  2008-04-25 20:42 marshalling objects Jacques Le Normand
@ 2008-04-26  6:45 ` Basile STARYNKEVITCH
  2008-04-26  7:42 ` Richard Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Basile STARYNKEVITCH @ 2008-04-26  6:45 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: caml-list

Jacques Le Normand wrote:
> 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?

First, a *.txt extension for a binary file (written thru Marshal.* 
functions) is very confusing.

Second, marshalling of any closures (including methods shared by 
objects) can only be unmarshalled by the exact same binary. So if you 
add/change code, it should not work.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


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

* Re: [Caml-list] marshalling objects
  2008-04-25 20:42 marshalling objects Jacques Le Normand
  2008-04-26  6:45 ` [Caml-list] " Basile STARYNKEVITCH
@ 2008-04-26  7:42 ` Richard Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Jones @ 2008-04-26  7:42 UTC (permalink / raw)
  To: Jacques Le Normand; +Cc: caml-list

On Fri, Apr 25, 2008 at 04:42:02PM -0400, Jacques Le Normand wrote:
> 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?

No.  What are you trying to accomplish?

Rich.

-- 
Richard Jones
Red Hat


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

* marshalling objects
@ 2005-11-11  4:54 Pietro Abate
  0 siblings, 0 replies; 4+ 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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-25 20:42 marshalling objects Jacques Le Normand
2008-04-26  6:45 ` [Caml-list] " Basile STARYNKEVITCH
2008-04-26  7:42 ` Richard Jones
  -- strict thread matches above, loose matches on Subject: below --
2005-11-11  4:54 Pietro Abate

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