From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA06387; Thu, 13 Dec 2001 21:26:45 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA06520 for ; Thu, 13 Dec 2001 21:26:44 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBDKQLv07021; Thu, 13 Dec 2001 21:26:21 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA06279; Thu, 13 Dec 2001 21:26:19 +0100 (MET) Date: Thu, 13 Dec 2001 21:26:19 +0100 From: Xavier Leroy To: Alain Frisch Cc: Willem Duminy , "Caml-List (E-mail)" Subject: Re: [Caml-list] Pairs vs. Records Message-ID: <20011213212619.B5755@pauillac.inria.fr> References: <20011211220928.C30744@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from frisch@clipper.ens.fr on Tue, Dec 11, 2001 at 10:48:22PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > This is very surprising indeed, because the OCaml compilers generate > > *exactly the same code* for building/accessing tuples and for > > building/accessing records (with no mutable fields). > > I guess you know this better than I ;) but one can observe difference in > generated code with pattern matching: > # fun x y -> match (x,y) with (a,b) -> a + b;; > # fun x y -> match {row=x;col=y} with {row=a;col=b} -> a + b;; Actually, you're correct. I was thinking in terms of using records or tuples inside data structures, but it's true that there are two "toplevel" uses of tuples that are optimized specially: one is for matching multiple values, as in your first example above; the other (specific to ocamlopt) is when passing a tuple of arguments to a known function that expects a tuple of the same size, e.g. let f (x, y) = ... ... f (e1, e2) ... Here, ocamlopt can avoid the construction of the pair, but similar code using records instead of pairs will not be optimized. Sorry for spreading misinformation :-) - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr