Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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)

with

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 ...

Cheers,
Christophe