• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Avoiding == and = mixup in if statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: Avoiding == and = mixup in if statements (From: Chris <email@hidden>)

  • Prev by Date: Re: Avoiding == and = mixup in if statements
  • Next by Date: Re: NSOpenGLView from a second NSThread
  • Previous by thread: Re: Avoiding == and = mixup in if statements
  • Next by thread: Re: Avoiding == and = mixup in if statements
  • Index(es):
    • Date
    • Thread