Browse thread
[Caml-list] Question
-
sebastien FURIC
-
Remi Vanicat
- sebastien FURIC
- Damien Doligez
- Pierre Weis
-
Remi Vanicat
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2003-12-01 (18:06) |
From: | sebastien FURIC <sebastien.furic@t...> |
Subject: | Re: [Caml-list] Question |
Remi Vanicat a écrit : > > "sebastien FURIC" <sebastien.furic@tni-valiosys.com> writes: > > > Hi, > > > > What do you think of the following code? > > > > # type toto = Toto of int | Titi of string;; > > type toto = Toto of int | Titi of string > > # let test t t' = match t, t' with > > | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0 > > -> "OK" > > | _ -> "KO";; > > Characters 73-79: > > Warning: this pattern is unused. > > | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0 > > -> "OK" > > ^^^^^^ > > I can't answer to your question, but with your example, one can do a: > > # let test t t' = match t, t' with > | ((Toto _ | Titi _), Toto 0 > | Toto 0, (Toto _ | Titi _)) when x = 0 -> "OK" > | _ -> "KO";; > > of course, this is not generalizable to any test. I could have even write: # let test t t' = match t, t' with | _, Toto 0 | Toto 0, _ -> "OK" | _ -> "KO";; The point is that my example is extracted from a "serious" project where I wrote something like: | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when f(x) = 0 -> ... and where type toto has more than 2 constructors. Cheers, Sébastien. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners