Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Pattern matching missing (or brain damage?)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William Lovas <wlovas@s...>
Subject: Re: [Caml-list] Pattern matching missing (or brain damage?)
On Fri, Jul 19, 2002 at 12:22:44AM +0200, Alessandro Baretta wrote:
> I believe I remember a pattern matching construct where an 
> expression could be associated with multiple patterns.
> 
> match <expr> with
> | A(_) | B(_) | C(_) -> foo
> | C(_) | D(_) | E(_) -> bar
> 
> Neither does the compiler accept such code, nor does the 
> manual mention such construct. Has it been removed from the 
> language or am I suffering severe brain damage from too much 
> O'Caml coding?

This is legal.  It's covered in the Chapter 6 of the manual, under
Patterns, sub-heading ``Or'' patterns:

    http://caml.inria.fr/ocaml/htmlman/manual014.html

You might be having trouble if your subpatterns don't bind exactly 
the same variables...

William
-------------------
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