From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 575887F712 for ; Fri, 24 Jan 2014 09:22:36 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=pra; client-ip=84.93.230.250; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=mailfrom; client-ip=84.93.230.250; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@avasout05.plus.net) identity=helo; client-ip=84.93.230.250; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="postmaster@avasout05.plus.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYCAHsi4lJUXeb6lWdsb2JhbABarhKSRIEMFg4BAQEBBw0JCRIqgiUBAQEECAIwPw0DAgkYLhkjGwIEHgWHecdoF48AB4Q4BI8onkk X-IPAS-Result: AqYCAHsi4lJUXeb6lWdsb2JhbABarhKSRIEMFg4BAQEBBw0JCRIqgiUBAQEECAIwPw0DAgkYLhkjGwIEHgWHecdoF48AB4Q4BI8onkk X-IronPort-AV: E=Sophos;i="4.95,711,1384297200"; d="scan'208";a="54652471" Received: from avasout05.plus.net ([84.93.230.250]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Jan 2014 09:22:35 +0100 Received: from XPS ([91.125.112.34]) by avasout05 with smtp id HkNZ1n0050kazHn01kNagD; Fri, 24 Jan 2014 08:22:35 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Db0u9JdW c=1 sm=1 tr=0 a=DvnplZMz9B0OTucJM+SM4w==:117 a=DvnplZMz9B0OTucJM+SM4w==:17 a=0Bzu9jTXAAAA:8 a=XCxr5DcLagoA:10 a=Xub9RBUEA-sA:10 a=Kvk-SOs2Z7YA:10 a=kj9zAlcOel0A:10 a=r2vSxAw-AAAA:8 a=BR64nyZ84HQA:10 a=T02_FekfsT79FsbtAi8A:9 a=CjuIK1q_8ugA:10 X-AUTH: jdh302:2500 Reply-To: From: "Jon Harrop" To: "'Yotam Barnoy'" Cc: "'Goswin von Brederlow'" , "'Ocaml Mailing List'" References: <20140120101654.GI26447@frosties> <08bc01cf17b8$9263d070$b72b7150$@ffconsultancy.com> <20140123092925.GB20624@frosties> <01c401cf1891$b1fb1360$15f13a20$@ffconsultancy.com> In-Reply-To: Date: Fri, 24 Jan 2014 08:22:43 -0000 Organization: Flying Frog Consultancy Ltd. Message-ID: <026101cf18dd$756c13d0$60443b70$@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHI4li4v5YdVc3QG7JLKEaISEVTZQITm23GAs0uvsEBcUwfGALv8TtSARGMS8wBZ0wNRppCHNOg Content-Language: en-gb Subject: RE: [Caml-list] How much optimized is the 'a option type ? Yotam wrote: > Just to clarify, by value types you mean stuff allocated on the stack, right? A value type is just an unboxed type like a C struct. A local variable of a value type is stored on the stack. A field inside a heap-allocated object that is a value type is stored inside the object and not in a separate object. An array of value types is a single contiguous block of memory with no pointers (e.g. an array of complex numbers). With value types you can almost completely avoid the garbage collector by replacing pointers with indices into an array of value types that acts as a pool allocator. This can be useful for avoiding GC latency and for optimizing for collections that violate the generational hypothesis (e.g. long-lived Sets and Maps). In HLVM, tuples were value types. For example, an (int * float) array is represented as a single contiguous block of memory. In constrast, OCaml represents this is an array of pointers to pairs where the second element is another pointer to a boxed float. Value types and reified generics permit very efficient hash tables. For example, the Dictionary type on .NET does not contain any pointers. Cheers, Jon.