Version française
Home     About     Download     Resources     Contact us    
Browse thread
Strange matching-problem... ?!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frederic van der Plancke <fvdp@d...>
Subject: Re: [Caml-list] Strange matching-problem... ?!


Oliver Bandel wrote:
> # match Foo with
>   _Bar -> "bar"
>   | Foo -> "foo";;
> Warning: this match case is unused.
> - : string = "bar"
> 
> # type foobar2 = _Foo | Bar;;
> Syntax error
> #
> 
> Why is the second match working without any error message?
> Did I ovelooked something?
> 
> I found that behaviour, after I tried to
> use Sumtypes starting with an "_" in the name.

Doesn't _ work as a lowercase letter ?
Then _Foo and _Bar are not valid sum type tags, but they are valid
variable names hence 

   match Foo with
   _Bar -> "bar"
   | Foo -> "foo";;

works exactly like

   match Foo with
   x -> "bar"
   | Foo -> "foo";;

would.


Frédéric