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
[Caml-list] "Or" patterns when both matchings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-28 (11:03)
From: Pixel <pixel@m...>
Subject: [Caml-list] "Or" patterns when both matchings

from the documentation:
  The pattern pattern1 | pattern2 represents the logical ``or'' of the two
  patterns pattern1 and pattern2. [...] If both matchings succeed, it is
  undefined which set of bindings is selected.

is there a reason for not using the classical pattern matching rule, to make
the ordering matters? (i've been nastily beat by this :-/)


type foo = Bar | Foo of foo

let f1 = function
  | Foo(a) 
  | a -> a

let f2 = function
  | Foo(a) -> a
  | a -> a

let e1 = f1 (Foo Bar)  (*=> Foo Bar *)
let e2 = f2 (Foo Bar)  (*=> Bar *)

Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr