Version française
Home     About     Download     Resources     Contact us    
Browse thread
Feature request : Tuples vs. records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Feature request : Tuples vs. records
On Thursday 22 February 2007 13:55, David Teller wrote:
> Yes, that's actually the only real difference I see between records and
> tuples. I have the feeling that every other difference is just syntactic
> sugar.
>
> Now, unless I'm mistaken, OCaml's design is mostly towards structural
> typing. Usually, when one wants nominal typing, one resorts to abstract
> types safely hidden in modules. From this point of view, nominal typing
> of records is therefore somewhat surprising.
>
> Am I getting something wrong ?

Structural typing is weaker. So tuples are only suitable for simple cases 
(primarily returning pairs of values from functions). Whenever things get 
complicated (>3 fields) you should switch to records.

Structural typing is often slower. So records are preferable when performance 
is critical.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists