English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2007-02-22 (15:50)
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