caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: j.romildo@gmail.com
To: caml-list@inria.fr
Subject: record field access
Date: Sat, 21 Oct 2006 00:53:58 -0300	[thread overview]
Message-ID: <20061021035358.GB15596@malaquias.gwiceb1> (raw)

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


             reply	other threads:[~2006-10-21  3:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-21  3:53 j.romildo [this message]
2006-10-21  7:23 ` [Caml-list] " Jon Harrop
2006-10-21 14:07   ` Christophe Raffalli

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=20061021035358.GB15596@malaquias.gwiceb1 \
    --to=j.romildo@gmail.com \
    --cc=caml-list@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).