why is this legal
Martin Norbäck
d95mback@dtek.chalmers.se
02 Feb 2002 17:30:06 +0100
lör 2002-02-02 klockan 16.03 skrev Antony Courtney:
> Of course, good compilers/tools will let you turn such warnings on and
> off selectively, and good programmers write programs that compile
> without warnings (since warnings usually indicate dubious constructs).
> While the examples you give are valid, I'm not convinced they are common
> enough that a warning would become a nuisance.
Ghc warns for this if you give the option -fwarn-name-shadowing.
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.
Regards,
Martin