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-15 (02:37)
From: Yaron Minsky <yminsky@g...>
Subject: Re: [Caml-list] pattern matching and records vs tuples
On Tue, Apr 14, 2009 at 9:46 PM, Pal-Kristian Engstad <
pal_engstad@naughtydog.com> wrote:

>  Honestly, I'd prefer to have to annotate non-exhaustive records:
>     let { foo = foo; bar = bar } = x
> should only match { foo; bar }, but
>     let { foo = foo; bar =  bar; .. } = x,
> can match records with more labels.

You're right, that seems way better.  The syntax is really much clearer, and
I like exhaustiveness as the default.  The only problem is that it is
inconsistent with the current way the compiler behaves.  But if you add the
exhaustiveness checking only as a flag, and that flag is turned off by the
"...", then you're totally set.  That's very consistent with other checks in
the compiler, such as checks for unused variables.

I think this is a great suggestion.  I'm curious what Xavier thinks...