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] Problem marshaling functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-30 (16:41)
From: christophe.gensoul@e...
Subject: [Caml-list] Problem marshaling functions
Hi list,

I am working on a project in which function marshalling is of a great use.
Actually I want to marshal and then send over the network list of partially
applied functions (always top level functions). However the behaviour of such
marshalling is not what I had expected.

Actually I would like the following code to pass the assert :

let a = ref 3;;

let f() = !a

let main () =
   let s = Marshal.to_string f [] in
   a := !a + 1;
   let g = Marshal.from_string s 0 in
   assert(g () = !a)

let () = main ()

The problem here is that the whole envirronment of the function seems to be
marshaled (all its dependencies).

Since the my programs all run the same code (imposed by function marshalling)
wouldn't it be possible to marshal all free variables of the function "by
reference". What I mean by that is that istead of marshalling the value of free
variables, I'd like to marshal adresses of such variables.

What I want to achieve is that all the state that is access in the function
doesn't travel with it. When arriving at destination, I want to use the state of
the destination (it's the same program on both side).

The only thing I can imagine for achieving that is to modify the way marshaling
does its job. But I really don't know how it work and where I should look in the
source for changing that.

Is it possible? If yes.
Is it very complicated to do?
Should it take a long time to achieve?
Where can I find documentation on the implementation of the marshalling in OCaml?

Thanks for any help.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: