Warnings at compile time for possible runtime pattern matching failure 
Author Message
 Warnings at compile time for possible runtime pattern matching failure

I've heard that some versions of ML give a warning when a function
definition is such that for some possible arguments, pattern matching
will fail.  Do Haskells and gofer optionally give such warnings?  
(If you ignore | guards, this would seem feasible.)  

For example, in gofer the definition

   f [] [] = []

will generate a runtime error for calls like

   f [] (h:t)
   f (h:t) []

Warnings in cases like this would "catch" a lot of additional errors
at compile time and would be especially appreciated by novice
programmers.




Mon, 19 Oct 1998 03:00:00 GMT  
 Warnings at compile time for possible runtime pattern matching failure

   I've heard that some versions of ML give a warning when a function
   definition is such that for some possible arguments, pattern matching
   will fail.

The Definition of Standard ML requires this. Section 6.5:

Recall from section 4.11 that in the context "fn <match>", the <match>
must be irredundant and exhustive, and that the compiler should flag
the match if it violates these restrictions. The exception "Match" can
only be raised for a match which is not exhaustive, and has therefore
been flagged by the compiler.

For each value binding "<pat> = <exp>" the compiler must issue a
report (but still compile) if _either_ <pat> is not exhaustive _or_
<pat> contains no variable .... However, these warnings should not be
given when the binding is a component of a top-level declaration "val
<valbind>" ....

Nick Barnes, speaking for himself



Mon, 19 Oct 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Compiling pattern matching Author Lennart Augustsson

2. eval-time macro-pattern matching

3. Is it possible so write part of code that will be compiled runtime

4. iss-matching - the free Regular Expression / Pattern Matching cluster

5. Compile time warnings

6. Difference between compile-time and runtime?

7. setting TK_NO_SECURITY at compile time (why not runtime?)

8. regex.error: match failure

9. regex.error: match failure

10. My first regex.error: match failure

11. regex error : match failure

12. "match failure" error

 

 
Powered by phpBB® Forum Software