Re: Avoiding == and = mixup in if statements
Re: Avoiding == and = mixup in if statements
- Subject: Re: Avoiding == and = mixup in if statements
- From: Ondra Cada <email@hidden>
- Date: Fri, 21 May 2004 20:47:07 +0200
Chris,
On 21.5.2004, at 20:39, Chris wrote:
>
To stray back "on topic", how touchy is -Wparentheses? Would
>
while(myObj = [iterator nextObj]) cause it to warn? I imagine
>
pre-processor directives exist to enable/disable the warning around
>
known ok blocks? Where possible I like to make sure that no warnings
>
are being generated.
In this case, I would recommend making sure by using "while ((o=[en
nextObj])) ...", since the compiler really cannot distinguish the case
from some "while (o==[foo currentItem]) [foo tryNextItem]" or alike ;)
Myself, I just use double parentheses around assigns even if the
-Wparentheses is switched off (or if I use a compiler which does not
support it), for the benefit of the reader: such a code is
intention-revealing, and it's self-evident that both "while (foo=bar)"
and "while ((foo==bar))" are typos. Again, of course, just a matter of
a personal preferences...
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.