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 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 2812BBBCA for ; Sat, 10 May 2008 10:51:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoBAFr+JEjAXQImiGdsb2JhbACSCQEBAQ8gmFk X-IronPort-AV: E=Sophos;i="4.27,464,1204498800"; d="scan'208";a="10573828" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 May 2008 10:51:42 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m4A8pgsf012354 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sat, 10 May 2008 10:51:42 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoBAFr+JEhQRFuwiGdsb2JhbACSCQEBAQ8gmFk X-IronPort-AV: E=Sophos;i="4.27,464,1204498800"; d="scan'208";a="12062993" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 May 2008 10:51:42 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Juknt-00013c-LE; Sat, 10 May 2008 09:51:41 +0100 Date: Sat, 10 May 2008 09:51:41 +0100 To: Berke Durak Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Why OCaml rocks Message-ID: <20080510085141.GA2716@annexia.org> References: <200805090609.36123.jon@ffconsultancy.com> <1210331526.17578.32.camel@flake.lan.gerd-stolpmann.de> <200805091910.41381.jon@ffconsultancy.com> <1210365645.17578.88.camel@flake.lan.gerd-stolpmann.de> <9d3ec8300805091400q1ed60bf8x95e31814ebf62473@mail.gmail.com> <20080509222603.GA21613@annexia.org> <20080510075205.GA2043@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 4825621E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 0200,:01 berke:01 durak:01 ad-hoc:01 marshalling:01 hashing:01 hashing:01 threading:01 mutexes:01 ad-hoc:01 marshalling:01 marshaling:01 ocaml:01 mlvalues:01 On Sat, May 10, 2008 at 10:24:50AM +0200, Berke Durak wrote: > > (1) Ad-hoc polymorphic primitives (structural equality, marshalling > > and hashing) do not work on ancient data structures, meaning that you > > will need to provide your own comparison and hashing functions. For > > more details see Xavier Leroy's response here: > > As you cannot mutate anything that is ancient (since it might be > concurrently > accessed), There are various restrictions on mutating the ancient data, which are explained in the README. It is not true that ancient data is completely immutable, just that you really need to understand what you're doing in order to do it correctly. There are additional restrictions to mutating [any] data concurrently, but I didn't explain those because they are obvious, and can be solved with standard threading techniques (mutexes, etc.).. > you cannot mark or modify them in-place for ad-hoc marshalling or > deep copying. Is that correct? I'm not sure what this means. I haven't tried to Marshal ancient data, because ancient data can already be persisted, so marshaling it doesn't make much sense. 'Deep copying' of ancient data can be done just like deep copying any other OCaml value. > Comparison does not mark (and thus does not work on cyclic structures). > Does it work on values in the ancient heap (I'm not talking of handles > here)? Your use of 'value', 'handle' etc. is confusing me. I suggest you take a look at how OCaml values are stored (eg. is a good place to start). Anyhow, the polymorphic primitives (like %compare) don't work, just because they make the assumption that anything outside the normal OCaml heap is incomparable, but you can certainly write your own comparison functions to replace those, eg. comparing character-by-character for strings. This has nothing to do with 'marking'. > So it seems that adding a generic copy-out-of-the-ancient heap function > (which marks in a private area) would be worthwhile. Should not be too > difficult. As I said earlier, you can just copy values from the ancient heap as you would any other value, eg. using { ... with ... } syntax or Array.copy / String.copy etc. Let's say this again. Values on the ancient heap look just like values anywhere else in the program. You can pass them to functions, print them out, add them up, do whatever else you would normally do, with very few restrictions. The differences are: - the polymorphic primitives don't work (so you can't compare or hash them) - they don't get garbage collected - you should be very careful about mutating them Rich. -- Richard Jones Red Hat