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
partial match in let
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-11-29 (22:30)
From: Robert W. <slrn_robert@y...>
Subject: Re: [Caml-list] partial match in let
Christophe Raffalli schrieb:

> Wish: I had like a way to avoid the partial match warning in code like
> let [x;y] = f (x) in foo
> Because if foo is long writing
> match f(x) with [x;y] -> foo | _ -> assert false

Wouldn't this be semantically equivalent to the constant function 
returning foo?
What I mean, instead of explicitly adding the wild card pattern, you can 
can substitute another one without. This would lead to an exhaustive 
pattern matching as well.

> is really ennoying, especially if you have a long sequence of let.
> I find usefull the partial match warning for match and function but 
> not for let (if you write a let, I think you are aware that your 
> matching will be partial for any data type with more than one 
> constructor, you do not need a warning)

I'm sure, there are formal problems with partial matching leading to 
serious serious headaches, but I'll need some time to think about.