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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3E7BBBB81 for ; Fri, 24 Feb 2006 09:29:47 +0100 (CET) Received: from gw-eur4.philips.com (gw-eur4.philips.com [161.85.125.10]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1O8Tk46004706 for ; Fri, 24 Feb 2006 09:29:46 +0100 Received: from smtpscan-eur4.philips.com (smtpscan-eur4.mail.philips.com [130.144.57.167]) by gw-eur4.philips.com (Postfix) with ESMTP id 59BCE49708 for ; Fri, 24 Feb 2006 08:29:46 +0000 (UTC) Received: from smtpscan-eur4.philips.com (localhost [127.0.0.1]) by localhost.philips.com (Postfix) with ESMTP id 6BD1B59 for ; Fri, 24 Feb 2006 08:29:45 +0000 (GMT) Received: from smtprelay-eur2.philips.com (smtprelay-eur2.philips.com [130.144.57.171]) by smtpscan-eur4.philips.com (Postfix) with ESMTP id 3A04158 for ; Fri, 24 Feb 2006 08:29:45 +0000 (GMT) Received: from ehvrmh02.diamond.philips.com (ehvrmh02-srv.diamond.philips.com [130.139.27.125]) by smtprelay-eur2.philips.com (Postfix) with ESMTP id 658D63B for ; Fri, 24 Feb 2006 08:29:43 +0000 (GMT) In-Reply-To: <20060223185624.GA26907@old.davidb.org> To: caml-list@yquem.inria.fr Subject: also for tagged records? [Was: Re: [Caml-list] (int * int) <> int*int ?] MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.0.3 September 26, 2003 Message-ID: From: Sebastian Egner Date: Fri, 24 Feb 2006 09:27:06 +0100 X-MIMETrack: Serialize by Router on ehvrmh02/H/SERVER/PHILIPS(Release 6.5.3FP1HF291 | September 19, 2005) at 24/02/2006 09:28:26, Serialize complete at 24/02/2006 09:28:26 Content-Type: multipart/alternative; boundary="=_alternative 002E8C6AC125711F_=" X-Miltered: at concorde with ID 43FEC3FA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 compiler:01 constructors:01 ocaml:01 mutable:01 mutable:01 indirection:01 runtime:01 pointer:01 misses:01 ocaml:01 caml-list:01 compiler:01 constructors:01 indirection: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.1 required=5.0 tests=HTML_30_40,HTML_MESSAGE autolearn=disabled version=3.0.3 This is a multipart message in MIME format. --=_alternative 002E8C6AC125711F_= Content-Type: text/plain; charset="US-ASCII" > Consider > > type a = A of int * int > | B of (int * int) > > The result of A (3, 4) will be a two element tuple type tagged > appropriately for 'A' (in this case 0). > > The result of B (3, 4) will be a one element tuple type tagged for B, > with the single element referring to the two element tuple containing (3, > 4). > > Because tuples are generally immutable, there is little semantic > difference, but the compiler does have to keep track of which is which. In > most cases I would guess that 'A' would be more efficient (unless there are > lots of larger constructors sharing the same tuple). Is there a similar way as 'A' above for records? This isn't valid Ocaml: type a = A of {mutable xA: int; mutable yA: int} | B of xyB and xyB = {mutable xB: int; mutable yB: int} Background: I had a case (a search tree data strucuture) where the additional indirection results in a 30% runtime penalty, due to increased pointer chasing (cache misses). It is the way it is in Ocaml and probably hard to change, but I would like to understand if there are fundamental reasons for it to be necessary or not. See also: http://caml.inria.fr/pub/ml-archives/caml-list/2005/11/9a6dcbcb4f3b4c0ebe9cdf28ac3d289b.en.html Sebastian. --=_alternative 002E8C6AC125711F_= Content-Type: text/html; charset="US-ASCII"
> Consider
>
>   type a = A of int * int
>          | B of (int * int)
>
> The result of   A (3, 4)  will be a two element tuple type tagged
> appropriately for 'A' (in this case 0).
>
> The result of   B (3, 4)  will be a one element tuple type tagged for B,
> with the single element referring to the two element tuple containing (3,
> 4).
>
> Because tuples are generally immutable, there is little semantic
> difference, but the compiler does have to keep track of which is which.  In
> most cases I would guess that 'A' would be more efficient (unless there are
> lots of larger constructors sharing the same tuple).


Is there a similar way as 'A' above for records?

This isn't valid Ocaml:

type a = A of {mutable xA: int; mutable yA: int}
       | B of xyB
and xyB = {mutable xB: int; mutable yB: int}

Background: I had a case (a search tree data strucuture) where
the additional indirection results in a 30% runtime penalty,
due to increased pointer chasing (cache misses). It is the
way it is in Ocaml and probably hard to change, but I would
like to understand if there are fundamental reasons for it to
be necessary or not. See also:

http://caml.inria.fr/pub/ml-archives/caml-list/2005/11/9a6dcbcb4f3b4c0ebe9cdf28ac3d289b.en.html

Sebastian.
--=_alternative 002E8C6AC125711F_=--