[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | j.romildo@g... |
| Subject: | record field access |
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