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
pattern matching and records vs tuples
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-14 (19:57)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: Re: [Caml-list] pattern matching and records vs tuples

Dear list member,

A solution
 when you change a record (or the meaning of an integer) and want to 
make sure that you are warned by the compiler at
every place where this data is used is to encapsulate your type in a box 
replacing for instance

let x = 0 : int (number of eggs)


let box d = `A(d) and unbox (`A d) = d
let x = box 0 (*nomber of dozen of eggs*)

Once you have updated all your code, you can remove the "box" and "unbox".

It would be nice if all this could be automated ...