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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 96A29BBAF for ; Thu, 24 Dec 2009 14:00:18 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiADAGL0MkvZSMDdi2dsb2JhbACBSpoOAQoLCgcRBbhuhDME X-IronPort-AV: E=Sophos;i="4.47,449,1257116400"; d="scan'208";a="39282456" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Dec 2009 14:00:18 +0100 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id CD4AC14329DD5; Thu, 24 Dec 2009 14:00:17 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NNnGk-0007QV-00; Thu, 24 Dec 2009 13:58:18 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1NNnGk-00051b-AN; Thu, 24 Dec 2009 13:58:18 +0100 From: Goswin von Brederlow To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: multicore wish References: <4B2D2BC1.6020204@msu.edu> <200912221912.51017.jon@ffconsultancy.com> <4B3109B8.1090406@gmail.com> <200912221920.29008.jon@ffconsultancy.com> Date: Thu, 24 Dec 2009 13:58:18 +0100 In-Reply-To: <200912221920.29008.jon@ffconsultancy.com> (Jon Harrop's message of "Tue, 22 Dec 2009 19:20:28 +0000") Message-ID: <87vdfw5y1h.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.22 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: X-Provags-ID: X-Spam: no; 0.00; ocaml:01 pointers:01 ocaml:01 pointers:01 structs:01 pointer:01 pointer:01 arrays:01 mutable:01 val:01 val:01 2009:98 edgar:98 2009:98 freeing:98 Jon Harrop writes: > On Tuesday 22 December 2009 18:02:32 Edgar Friendly wrote: >> On 12/22/2009 01:12 PM, Jon Harrop wrote: >> > On Tuesday 22 December 2009 13:09:27 Goswin von Brederlow wrote: >> >> The advantage with ocaml though is that you never have pointers into a >> >> structure. Makes thinks a lot simpler for the GC and avoids large >> >> overheads in memory. >> > >> > I don't understand what you mean by OCaml "never has pointers into a >> > structure". Half the problem with OCaml is that OCaml almost always uses >> > pointers and the programmer has no choice, e.g. for complex numbers. >> >> I think he means that ocaml structs (records, tuples) will only ever >> have pointers pointing to their beginning - you can't have a pointer to >> somewhere in the middle of a structure. Exactly. > If so then I do not understand the relevance. You cannot have pointers into a > structure in F# or HLVM either... If you have an array a of (int * int) then in ocaml a is an array of pointers to tuples. a.(5) is a pointer to the 6th tuple. You said that in F# the array will be really an array of tuples. Then a.(5) will be a pointer into the array at the position where the 6th tuple is. It does not point to the begining of an allocated block but to the middle of one. That means as long as a.(5) is reachable the full array has to remain allocated or the GC has to recognise that only one (a few) items of an array are reachable and copy them before freeing the array. The GC also needs a way to find the begining of an allocated block from a pointer into the block. Which means extra overhead in both memory and time. Another think is that tuples are immutable but arrays are mutable. In ocaml you get this nice behaviour: # let a = Array.init 5 (fun x -> (x,x));; val a : (int * int) array = [|(0, 0); (1, 1); (2, 2); (3, 3); (4, 4)|] # let x = a.(1);; val x : int * int = (1, 1) # a.(1) <- (2,2);; - : unit = () # x;; - : int * int = (1, 1) In F# you would get (2,2) for your fast sortable array. A different semantic. MfG Goswin