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
ANN: pretty-printing, type-safe marshalling, dynamic typing for free.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-20 (10:24)
From: Jeremy Yallop <jeremy.yallop@e...>
Subject: Re: [Caml-list] ANN: pretty-printing, type-safe marshalling, dynamic typing for free.
Joel Reymont wrote:
> On Jun 20, 2007, at 1:14 AM, Jeremy Yallop wrote:
>> Serialisation (marshalling):
>>    Shelve.shelveS<point tree> points
>>    =>
>> "\007\003\t\128\128\128\128\128\128\128\248?\t\128\128\128\128\128\128\128\128@\001\000\005\000\001\008\000\001\n\001\003\004\t\003\000\001\012\001\003\006\011\005\005\002\002\000\002\000\002\002\000\000\002\001\001\002\002\002" 
> Aha! Now I can implement a Sexp library for 3.10!
> What is the difference between pickling and shelving, though?

In `deriving' Pickle is a fairly naive value-oriented serialiser.  It 
doesn't do any structure sharing: the same value can be repeated several 
times in the output.  It doesn't preserve cycles, so it's not available 
for mutable values.  You can customize Pickle by writing your own 
definition for a particular type.

Shelve handles cycles correctly and minimises values so the output is 
potentially much smaller.  It also provides a different means of 
specialization: by giving a custom definition of equality for a type you 
can increase opportunities for sharing.  It's currently rather slow for 
large values, but I expect that to change in the next release.  Shelve 
is built on top of Pickle, FWIW.

The choice of names is pretty arbitrary: I wrote Pickle first, then I 
needed another name when I wrote Shelve.