From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 13D42BB81 for ; Sun, 25 Sep 2005 23:32:03 +0200 (CEST) Received: from web26805.mail.ukl.yahoo.com (web26805.mail.ukl.yahoo.com [217.146.176.81]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id j8PLW2Jl029882 for ; Sun, 25 Sep 2005 23:32:02 +0200 Received: (qmail 32864 invoked by uid 60001); 25 Sep 2005 21:32:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Wd8KBZFcLXaezBhtWLBNiEU2ZP4E9rCP8S+Vj5qEyEHLpkAIsOd7pYdKgnnTLJWDJMtn2L1yqayfmtrc7csawwZdC5JG7HhAuE/4Gc5loFVqQ4N7WM+6m1xMJuTgqD70cmV0YXyKJy02f1mD9iajh8Jd4k/tu6zKLsx73dxCUgc= ; Message-ID: <20050925213202.32862.qmail@web26805.mail.ukl.yahoo.com> Received: from [83.180.68.182] by web26805.mail.ukl.yahoo.com via HTTP; Sun, 25 Sep 2005 23:32:02 CEST Date: Sun, 25 Sep 2005 23:32:02 +0200 (CEST) From: Martin Chabr Subject: Avoiding shared data To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 43371752.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; avoiding:01 ocaml:01 ocaml:01 marshaling:01 arrays:01 pairs:01 integers:01 arrays:01 marshaling:01 unmarshaling:01 ...:98 2000,:98 auf:98 ihre:98 constants:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.0.3 Working with non-shared data structures in OCaml Deep copy of OCaml structures, marshaling ================================================ Dear group members, I need to process arrays of pairs of integers and records ((int * record) array) in which all elements must be updated individually, which means that unshared data structures must be used. For arrays of arrays I can produce unshared data by using the library functions Array.copy and Array.append to append the individual arrays into the embedding array. It works, the low level arrays can be updated individually. But I cannot use the same scheme to the array of the (int * record) structures, because I do not know how to copy these structures to dissolve the sharing. I do not even know how to copy records. It seems to me that this problem occurs always when I want to produce an array of data with a fixed structure automatically (rather than entering the array [| ... |] by hand at the top level interpreter using constants only). How can I produce completely unshared structures? What about marshaling and unmarshaling the data? This should produce a deep copy of data objects. I have tried it, it works, but it seems to me wasteful to copy all the data twice only to get rid of the sharing. It would be great to know of a completely general (any nested structures) and fast solution (without copying) how to produce unshared data structures. My environment is OCaml 3.08.02 for Windows on Win 2000, New Windows Interface v1.9RC4. I am looking forward to you reply. Regards, Martin Martin Chabr Hochstrasse 28 8044 Zürich Schweiz / Switzerland Tel.P.: 01-261 17 24 ___________________________________________________________ Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx