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
RE: [Caml-list] Record pattern matching
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-05-10 (18:43)
From: Don Syme <dsyme@m...>
Subject: RE: [Caml-list] Record pattern matching
> > I guess this is considered a feature, but I just wanted to report
> > in my current situation I actually find it unhelpful. 
> 	You'd rather be forced to code something like:
> 	function { a=a; b=_ } -> a;;
> where all the fields have to be named, but some of them can 
> be specified as ignored?

I guess the point is that I don't use record pattern matching much, and
where I do I don't want partial matches.  Or at least I have a cases
where enforcing full matching would catch more bugs.  For example, if
I'm writing marshalling code for the record by hand I want the type
system to tell me if I have forgotten to marshal a field.

> There is a sense in which
> 	record.a
> is just a shorthand for
> 	match record with { a=value } -> value
> which means that you might argue that the notation 
> 	record.a
> should be completed by naming every field too :-)

You could argue that, but I wouldn't....

To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr