From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id AD26BBBCA for ; Thu, 28 Feb 2008 23:09:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAAfAxkc+BBFogGdsb2JhbACBVo8aAQEJBAYHCp0v X-IronPort-AV: E=Sophos;i="4.25,422,1199660400"; d="scan'208";a="8740804" Received: from smtp-104-thursday.noc.nerim.net (HELO mallaury.nerim.net) ([62.4.17.104]) by mail1-smtp-roc.national.inria.fr with ESMTP; 28 Feb 2008 23:09:46 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by mallaury.nerim.net (Postfix) with ESMTP id 1F9DB4F45F; Thu, 28 Feb 2008 23:09:33 +0100 (CET) Received: from [192.168.0.1] (glinka.lesours [192.168.0.1]) by hector.lesours (Postfix) with ESMTP id C498F20F0FE; Thu, 28 Feb 2008 23:09:26 +0100 (CET) Message-ID: <47C73121.2060809@starynkevitch.net> Date: Thu, 28 Feb 2008 23:09:37 +0100 From: Basile STARYNKEVITCH User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080109) MIME-Version: 1.0 To: Dario Teixeira Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Long-term storage of values References: <191751.36007.qm@web54607.mail.re2.yahoo.com> In-Reply-To: <191751.36007.qm@web54607.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 ocaml:01 moscova:01 arrays:01 faiencerie:01 92340:01 reine:01 closures:01 closures:01 wrote:01 abstract:01 abstract:01 cristal:01 caml-list:01 Dario Teixeira wrote: > Hi, > > Suppose I have a value of type Story.t, fairly complex in its definition. > I wish to store this value in a DB (like Postgresql) for posterity. > At the moment, I am storing in the DB the marshalled representation > of the data; whenever I need to use it again in the Ocaml programme > I simply fetch it from the DB and unmarshal it. > > This works fine; there is however one nagging problem: the marshalled > representation is brittle. If Story.t changes even slightly, I will > no longer be able to retrieve values marshalled with the old version. It is even theoretically a very difficult problem. There have been some publications by Cristal, Moscova, Gallium people at INRIA. Assuming you have no abstract types, no objects, and no closures, and no polymorphisms i.e. that there is a *.ml source file containing all the type definitions. Then the types are composed by base types (int, string, ...), sums, records, and perhaps arrays. Then you could consider what are the deltas on the type definition. In a sum like type sumt = A of t1 | B of t2 | C you might consider what happens when you remove let say B, or add let's say a choice | D of t3 In a record, consider likewise what happens when adding or removing a field. Etc.... The details are very complex (at least to me, who tried unsucessfully to work on this during my year at INRIA). Maybe a semi-hand-crafted generator could help. Adding polymorphisms, closures, objects, abstract types is a big mess. Good luck to you. Try to publish something. Regards -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***