why is this legal
Zhanyong Wan
zhanyong.wan@yale.edu
Sat, 2 Feb 2002 12:22:10 -0500
Martin Norbäck wrote:
| However, it's extremely common to write code like this:
|
| f expr = case expr of
| EXPR_NOT expr -> something with expr
| EXPR_UNARY_MINUS expr -> something with expr
|
| not allowing this would make the programmer have to invent new names
| here. I had to turn off this warning for the project we do at work,
| because the compiler would emit hundreds of warnings for cases like
| this. Changing all bound names was not a good option.
I agree with Antony on that compilers should emit warnings on
potentially-dangerous usages. Anyone working on a lint for Haskell? :-)
It would be a valuable contribution to our community.
On the other hand, I think Martin has a reasonable concern. However, note
that in Hal's original example:
| f x = f' 0 x
| where f' acc [] = acc
| f acc (x:xs) = f' (x+acc) xs
the inner f is never used. Therefore I believe -fwarn-unused-local-binding
(if there is such an option) will detect the bug in Hal's code without
flooding stderr in Martin's case.
- Zhanyong