in reply to Re: Avoiding the == blues in thread Avoiding the == blues
You are absolutely correct, of course, but this doesn't work for other languages, or for badly written scripts which generate thousands of warnings that you have to maintain. :)
Re^3: Avoiding the == blues
by gaal (Parson) on Dec 29, 2004 at 20:26 UTC
|
In some other languages, if takes a boolean, which is (deliberately) not what an assignment returns, so if (x = 0) doesn't get past the compiler. | [reply] [d/l] [select] |
Re^3: Avoiding the == blues
by Anonymous Monk on Dec 30, 2004 at 10:07 UTC
|
Well, saying "other languages" isn't quite correct, as it's the compiler that will issue a warning, if any. And gcc with -Wall will. It will even catch cases like:
if (x = y)
unlike Perls -w, which will let you do
if ($x = $y)
while keeping silent. | [reply] [d/l] [select] |
|