caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* pattern matching and records vs tuples
@ 2009-04-14 14:12 Yoann Padioleau
  2009-04-14 16:00 ` [Caml-list] " Christophe TROESTLER
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Yoann Padioleau @ 2009-04-14 14:12 UTC (permalink / raw)
  To: caml-list


Hi, 

I've found that while records provide advantages over tuples, 
they also have disadvantages when it comes to evolution issues. 
If I decide to evolve code using a tuple type, for instance adding
new information and so extend a 4-uple in a 5-uple, then the compiler
will tell me all the places that I need to update, which is good.
If I use records instead, and have 4 fields, and I want to add again
some new information in a new field, then the way the compiler works
right now will not help me at all. E.g with this code 

  type record = { 
    field1: int;
    field2: int;
  }
  let foo = function 
   { field1 = v1; field2 = v2 } -> ...


If I extend record with a new field   field3, then ocaml will
not warn me and tell me to modify also the 'foo' function :(


So, would it be possible to extend the ocaml compiler with a simple
feature that let the programmer tell the compiler when he use 
an "exhaustive" pattern with record, e.g.

 let foo = function
 { field1 = v1; field2 = v2; NOTHING_ELSE} -> 

(the inverse of a '...')


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-04-17 21:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 14:12 pattern matching and records vs tuples Yoann Padioleau
2009-04-14 16:00 ` [Caml-list] " Christophe TROESTLER
2009-04-14 16:40 ` Goswin von Brederlow
2009-04-14 16:58   ` Yoann Padioleau
2009-04-14 20:01     ` Christophe Raffalli
2009-04-15  0:44 ` Yaron Minsky
2009-04-15  1:46   ` Pal-Kristian Engstad
2009-04-15  2:37     ` Yaron Minsky
2009-04-15  2:40     ` Ashish Agarwal
2009-04-16 16:05     ` Goswin von Brederlow
2009-04-16 16:59       ` David Allsopp
2009-04-17  0:26         ` Jacques Garrigue
2009-04-17 21:12         ` Goswin von Brederlow
2009-04-15  7:41   ` blue storm
2009-04-15  9:30     ` Martin Jambon
2009-04-15 11:01       ` Yaron Minsky
2009-04-15 12:04         ` Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).