From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 8A5BABC57 for ; Fri, 8 Oct 2010 15:45:34 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al4BADu9rkxRZ90snGdsb2JhbAChblEVAQEBAQEICwgJESK8DYVHBIUJhTc X-IronPort-AV: E=Sophos;i="4.57,302,1283724000"; d="scan'208";a="60788925" Received: from mtain04-winn.ispmail.ntl.com ([81.103.221.44]) by mail3-smtp-sop.national.inria.fr with ESMTP; 08 Oct 2010 15:45:34 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtain04-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20101008134533.JTQZ3020.mtain04-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Fri, 8 Oct 2010 14:45:33 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20101008134533.EHDO6697.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com>; Fri, 8 Oct 2010 14:45:33 +0100 Received: from remus.metastack.local ([172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id o98DjUTi019987 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 8 Oct 2010 14:45:30 +0100 Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%11]) with mapi; Fri, 8 Oct 2010 14:44:01 +0100 From: David Allsopp To: "'Jean Krivine'" , "'caml users'" Subject: RE: [Caml-list] Marshalling question Thread-Topic: [Caml-list] Marshalling question Thread-Index: AQHLZu3Po+YcAkka1021IF7mCkmCEJM3Djjw Date: Fri, 8 Oct 2010 13:39:57 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=0HkZrv5JJXf21mLXuGmLXmM6HNQ7zICno0hlPRwkeWw= c=1 sm=0 a=n9GluKJgdk8A:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=-wFowkN2o9XjeaFdz94A:9 a=hwnPMvceMxAUUwdXXOG0y1HfQwoA:4 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam: no; 0.00; marshalling:01 krivine:01 ocaml:01 arrays:01 hashtbl:01 runtime:01 runtime:01 marshalling:01 hashtbl:01 memoizing:01 equality:01 wrote:01 abstract:01 terminate:01 caml-list:01 Jean Krivine wrote: > Dear ocaml users, >=20 > A simple question: is it safe to marshalize a data structure that contain= s > imperative elements (like arrays or hashtbl) ? Simple answer: yes. Marshal works on the runtime representation of data whi= ch is imperative (immutability is enforced by the type system, not the runt= ime). > I found the documentation of the Marshal module rather obscure to me. > In particular it is not clear whether I should use the No_sharing flag. Unless you know how the data structures you are marshalling work, you shoul= d never use this flag (i.e. if you're working with an abstract data type li= ke Hashtbl.t then you certainly shouldn't be using this flag). The obvious = reason is that if the data contain a cycle that you're not aware of then yo= ur program will not terminate. Less obvious reasons include structures (e.g= . for memoizing) which rely on value sharing so that they can use physical,= rather than structural equality for speed. The worst thing that can happen= when this flag isn't given is that the operation might be a teensy bit slo= wer than it strictly needs to be. David=20