From: Sebastian Egner <sebastian.egner@philips.com>
To: caml-list@yquem.inria.fr
Subject: also for tagged records? [Was: Re: [Caml-list] (int * int) <> int*int ?]
Date: Fri, 24 Feb 2006 09:27:06 +0100 [thread overview]
Message-ID: <OF15A3F852.0606B44C-ONC125711F.002C18D7-C125711F.002E8C6E@philips.com> (raw)
In-Reply-To: <20060223185624.GA26907@old.davidb.org>
[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]
> 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.
[-- Attachment #2: Type: text/html, Size: 1935 bytes --]
next prev parent reply other threads:[~2006-02-24 8:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-23 17:28 (int * int) <> int*int ? Frédéric Gava
2006-02-23 18:33 ` [Caml-list] " Eric Cooper
2006-02-23 19:03 ` Martin Jambon
2006-02-23 19:07 ` Frédéric Gava
2006-02-23 20:15 ` Brian Hurt
2006-02-23 21:30 ` Frédéric Gava
2006-02-23 21:57 ` Brian Hurt
2006-02-23 22:30 ` Frédéric Gava
2006-02-23 22:50 ` Brian Hurt
2006-02-23 23:07 ` Frédéric Gava
2006-02-24 8:38 ` Alessandro Baretta
2006-02-24 12:59 ` Damien Doligez
2006-02-23 18:33 ` Thomas Fischbacher
2006-02-23 18:56 ` David Brown
2006-02-23 19:24 ` Frédéric Gava
2006-02-23 19:37 ` Frédéric Gava
2006-02-23 19:45 ` Frédéric Gava
2006-02-24 0:01 ` Jacques Garrigue
2006-02-24 0:18 ` Lukasz Stafiniak
2006-02-24 2:17 ` Jacques Garrigue
2006-02-24 13:07 ` Alain Frisch
2006-02-25 17:42 ` Vincent Balat
2006-02-25 18:30 ` Nicolas Pouillard
2006-02-25 19:09 ` Richard Jones
2006-03-01 12:48 ` Nicolas Pouillard
2006-02-25 23:17 ` Christophe TROESTLER
2006-03-01 13:01 ` Nicolas Pouillard
2006-02-27 11:14 ` camlp4 renovation [was: [Caml-list] (int * int) <> int*int ?] Hendrik Tews
2006-02-24 13:39 ` [Caml-list] (int * int) <> int*int ? Nicolas Cannasse
2006-02-24 14:49 ` Frédéric Gava
2006-02-24 8:27 ` Sebastian Egner [this message]
2006-02-24 14:01 ` also for tagged records? [Was: Re: [Caml-list] (int * int) <> int*int ?] Thomas Fischbacher
2006-02-23 20:58 ` [Caml-list] (int * int) <> int*int ? Jon Harrop
2006-02-23 21:36 ` Frédéric Gava
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OF15A3F852.0606B44C-ONC125711F.002C18D7-C125711F.002E8C6E@philips.com \
--to=sebastian.egner@philips.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).