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-12 (17:12)
From: Brian Rogoff <bpr@b...>
Subject: Re: [Caml-list] Record pattern matching
On Fri, 11 May 2001, Andreas Rossberg wrote:
> > >       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?
> No, but as Don suggested having alternative syntax would be preferable.
> SML for example distinguishes the patterns
> 	{a = p}
> and
> 	{a = p, ...}

This seems like a good solution to this problem.

> > 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.
> This has been my experience as well when modifying record types.

OK, just to provide another data point, I use the partial match feature
quite a bit. The "..." notation is light enough that the feature is still 
convenient, which would not be the case if each named field would have to
be explicitly named. I've also been reading a lot of SML code that I
haven't written lately and I find that notation quite readable and

As an aside, the situation with records is still not very satisfying. In
some cases I use objects when I really just want flexible records, where I 
can define functions over all records types with given fields. It seems
that would be more "symmetric" too, with respect to polymorphic variants.
I gather something like that has been tried already and found wanting?

-- Brian

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