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: Oliver Bandel <oliver@f...>
Subject: Strange matching-problem... ?!
Hello,

any idea about this?!





# type foobar = Foo | Bar;;
type foobar = Foo | Bar

# match Foo with
   Foo -> "foo"
  | Bar -> "bar";;
- : string = "foo"

# match Foo with
   _Foo -> "foo"
  |Bar -> "bar";;
Warning: this match case is unused.
- : string = "foo"

# match Foo with
  _ Foo -> "foo"
  | Bar -> "bar";;
Syntax error

# 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.

Using such things like _Foo instead of Foo
does not yield any error message, but when defining
the type with _Foo then ocaml complains about my
wrong syntax.

What's going on here and why?

TIA,
   Oliver