From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, NO_REAL_NAME,SPF_NEUTRAL autolearn=disabled version=3.1.3 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 24B30BC69 for ; Sat, 21 Oct 2006 05:54:43 +0200 (CEST) Received: from malaquias.no-ip.org ([200.131.216.204]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9L3sg91013249 for ; Sat, 21 Oct 2006 05:54:42 +0200 Received: by malaquias.no-ip.org (Postfix, from userid 500) id 02CB2CB0F6; Sat, 21 Oct 2006 00:53:59 -0300 (BRT) Date: Sat, 21 Oct 2006 00:53:58 -0300 From: j.romildo@gmail.com To: caml-list@inria.fr Subject: record field access Message-ID: <20061021035358.GB15596@malaquias.gwiceb1> Mail-Followup-To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-j-chkmail-Score: MSGID : 45399A02.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 45399A02.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; romildo:01 notation:01 sqrt:01 sqrt:01 romildo:01 tuples:01 float:03 float:03 let:03 let:03 pattern:04 preferable:04 preferable:04 declarations:04 matching:06 Hello. Regarding performance, is there any difference in accessing a record field using pattern matching and using the dot notation? For instance, given the declarations, type point = { x: float; y: float } let sqr x = x *. x let dist1 p q = sqrt (sqr (q.x -. p.x) +. sqr (q.y -. p.y)) let dist2 {x=x1; y = y1} {x=x2; y=y2} = sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1)) what should be preferable: dist1 or dist2? And to compare records with tuples, given also let dist3 (x1,y1) (x2,y2) = sqrt (sqr (x2 -. x1) +. sqr (y2 -. y1)) what should be preferable: dist2 or dist3, regarding performance? Romildo