Version française
Home     About     Download     Resources     Contact us    
Browse thread
Request for complete pattern matching
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin_jambon@e...>
Subject: Re: [Caml-list] Request for complete pattern matching
On Thu, 24 Nov 2005, Luc Maranget wrote:

>>> Typing and warnings are yet another issue!
>>
>> Warnings regarding incomplete match cases can be suppressed by adding
>> 'when true' guards and superfluous catch-all cases.
>
> I mean that you will probably loose significant warnings,
> with your idea you avoid spurious warnings.

Of course, but it's not worse than the equivalent if-then-else style that 
you would use otherwise, because in the general case there's no way of 
detecting missing or unused cases.

Pattern-matchings which don't use the syntax extension are conserved, so 
the warnings are still here like before in those cases.

See this session:

$ micmatch
         Objective Caml version 3.08.3

         Camlp4 Parsing version 3.08.3

# match Some "thing" with
       Some "abc" -> ()
     | None -> ();;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Some ""
Exception: Match_failure ("", 1, 0).
# match Some "thing" with
      Some / "t"* (_* as s) / -> s
    | None -> "none";;
- : string = "hing"
# match Some "thing" with
      Some / "the" _* as s / -> s
    | None -> "none";;
Exception: Match_failure ("", 5, -56).




Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr

Store and share your bioinformatics tips at http://wikiomics.org