Re: Unnecessary Boolean Warning

2011-08-04 Thread Sander Stoks
One important difference for instance is that if you write if (a() b()), both a() and b() will always be executed, while if you write if (a() b()), b() will be executed only if a() is true. The C language doesn't make any guarantees about that. While this optimisation is to be expected,

Re: Unnecessary Boolean Warning

2011-08-04 Thread Boyd Collier
At the risk of offending contributors to this list, whose knowledge and helpfulness I greatly respect, may I suggest that this thread has gone on long enough and that competing opinions on this topic would be better aired on some other list? Boyd___

Re: Unnecessary Boolean Warning

2011-08-03 Thread Dale Miller
You are correct. I get that wrong a lot. But that reinforces my point. A decent language (IMHO) would not confuse things with two different and's. And my typo '1001' for OX1001 probably was a Freudian slip because of my fervent dislike of C's syntax for hex numbers. Or maybe it was too

Re: Unnecessary Boolean Warning

2011-08-03 Thread Scott Ribe
On Aug 3, 2011, at 1:53 AM, Dale Miller wrote: A decent language (IMHO) would not confuse things with two different and's. Well, there *are* two different and's, regardless of whether your favored languages allow you access to both or not. -- Scott Ribe scott_r...@elevated-dev.com

Re: Unnecessary Boolean Warning

2011-08-03 Thread Thomas Davie
On 3 Aug 2011, at 14:29, Scott Ribe wrote: On Aug 3, 2011, at 1:53 AM, Dale Miller wrote: A decent language (IMHO) would not confuse things with two different and's. Well, there *are* two different and's, regardless of whether your favored languages allow you access to both or not. Not

Re: Unnecessary Boolean Warning

2011-08-03 Thread Scott Ribe
On Aug 3, 2011, at 7:54 AM, Thomas Davie wrote: Not really – both C ands are the same and… they're just operating on different representations of booleans. No, they're not the same at all. One is a bitwise operation on binary ints. -- Scott Ribe scott_r...@elevated-dev.com

Re: Unnecessary Boolean Warning

2011-08-03 Thread Thomas Davie
On 3 Aug 2011, at 15:15, Scott Ribe wrote: On Aug 3, 2011, at 7:54 AM, Thomas Davie wrote: Not really – both C ands are the same and… they're just operating on different representations of booleans. No, they're not the same at all. One is a bitwise operation on binary ints. Yes – it

Re: Unnecessary Boolean Warning

2011-08-03 Thread Jean-Daniel Dupas
Le 3 août 2011 à 16:40, Thomas Davie a écrit : On 3 Aug 2011, at 15:15, Scott Ribe wrote: On Aug 3, 2011, at 7:54 AM, Thomas Davie wrote: Not really – both C ands are the same and… they're just operating on different representations of booleans. No, they're not the same at all. One

Re: Unnecessary Boolean Warning

2011-08-03 Thread Graham Cox
On 04/08/2011, at 1:52 AM, Jean-Daniel Dupas wrote: One important difference for instance is that if you write if (a() b()), both a() and b() will always be executed, while if you write if (a() b()), b() will be executed only if a() is true. The C language doesn't make any guarantees

Re: Unnecessary Boolean Warning

2011-08-03 Thread Greg Parker
On Aug 3, 2011, at 5:56 PM, Graham Cox wrote: On 04/08/2011, at 1:52 AM, Jean-Daniel Dupas wrote: One important difference for instance is that if you write if (a() b()), both a() and b() will always be executed, while if you write if (a() b()), b() will be executed only if a() is true.

Re: Unnecessary Boolean Warning

2011-08-03 Thread Graham Cox
On 04/08/2011, at 11:19 AM, Greg Parker wrote: This is a classic question for coding job interviews. Incorrect. Ah well, I guess I didn't get the job :) In my defence, I saw this in a job interview but it was prior to 1999. Maybe C99 tightened up on something that was previously vague.

Re: Unnecessary Boolean Warning

2011-08-03 Thread Roland King
The C99 spec I can find on the net has 6.5.13 (3) and (4). 3. The operator shall yield 1 if both of it's operands compare unequal to 0; otherwise it yields 0. The result has type int. 4. Unlike the bitwise binary operator, the operator guarantees left-to-right evaluation; there is a

Re: Unnecessary Boolean Warning

2011-08-03 Thread glenn andreas
On Aug 3, 2011, at 8:27 PM, Graham Cox wrote: On 04/08/2011, at 11:19 AM, Greg Parker wrote: This is a classic question for coding job interviews. Incorrect. Ah well, I guess I didn't get the job :) In my defence, I saw this in a job interview but it was prior to 1999. Maybe

Re: Unnecessary Boolean Warning

2011-08-03 Thread Scott Ribe
On Aug 3, 2011, at 7:27 PM, Graham Cox wrote: In my defence, I saw this in a job interview but it was prior to 1999. Maybe C99 tightened up on something that was previously vague. Nope, been that way since KR 1st edition ;-) -- Scott Ribe scott_r...@elevated-dev.com

Re: Unnecessary Boolean Warning

2011-08-03 Thread Graham Cox
On 04/08/2011, at 11:36 AM, glenn andreas wrote: More likely the somebody that interviewed you didn't have it correct in the first place, scarring you for life... Well, that part's true :) I seem to recall I failed that question, the only one I did. So I got the lecture and never

Re: Unnecessary Boolean Warning

2011-08-03 Thread Preston Sumner
On Aug 3, 2011, at 8:10 PM, Andy Lee wrote: On Aug 3, 2011, at 9:51 PM, Graham Cox wrote: I think the point they wanted to get across was that they didn't want to see code like this: if( someFunction() someOtherFunction()){ ... } instead of: if( someFunction()) { if(

Re: Unnecessary Boolean Warning

2011-08-03 Thread Graham Cox
On 04/08/2011, at 1:17 PM, Preston Sumner wrote: I find short-circuit evaluation easier to read and much more concise, and, of course, it's always nice to avoid unnecessary levels of nesting. I wouldn't necessarily disagree, but companies often have their own coding standards that forbid

Re: Unnecessary Boolean Warning

2011-08-03 Thread Andy Lee
On Aug 3, 2011, at 11:20 PM, Graham Cox wrote: On 04/08/2011, at 1:17 PM, Preston Sumner wrote: I find short-circuit evaluation easier to read and much more concise, and, of course, it's always nice to avoid unnecessary levels of nesting. I wouldn't necessarily disagree, but companies

Unnecessary Boolean Warning

2011-08-02 Thread Dale Miller
Greg Parker wrote: A warning on '==' inside of 'if' is ridiculous. '==' is comparison for equality. =' is assignment. Anyone who can't at least keep these two straight shouldn't be doing programming. I'm glad that my bosses failed to discover my incompetence in my 40+years of programming in

Re: Unnecessary Boolean Warning

2011-08-02 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/2/11 5:57 PM, Dale Miller wrote: Greg Parker wrote: A warning on '==' inside of 'if' is ridiculous. '==' is comparison for equality. =' is assignment. Anyone who can't at least keep these two straight shouldn't be doing programming. ... I

Re: Unnecessary Boolean Warning

2011-08-02 Thread Dale Miller
Conrad Shultz notified me that I had misinterpreted Greg Parker's post. I will recant my accusation of hubris and apologize. Dale Miller ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator

Re: Unnecessary Boolean Warning

2011-08-01 Thread Gordon Apple
It¹s not that I object to anyone doing it, if that makes them more comfortable, but a warning on ³³² inside of ³||²² is ridiculous. Everyone knows that multiplication takes precedence over addition. ³² is a multiplication. ³||² is, welll, almost an addition. (Exor is addition in a mod 2

Re: Unnecessary Boolean Warning

2011-08-01 Thread Sean McBride
On Sun, 31 Jul 2011 15:13:45 -0500, Gordon Apple said: The following expression generates a warning message (32 within 3||2) and says to include the 3anded2 expression in parens. Anybody who understands basic boolean operator precedence knows this is unnecessary. Bug report? BOOL isInUse =

Re: Unnecessary Boolean Warning

2011-08-01 Thread Jean-Daniel Dupas
If this warning bother you, just disable it. clang is smart enough to tell you what flag you have to turn off in the warning message. For instance, just add -Wno-constant-logical-operand in your other warning flags. Le 1 août 2011 à 17:47, Gordon Apple a écrit : It’s not that I object to

Re: Unnecessary Boolean Warning

2011-08-01 Thread Greg Parker
On Aug 1, 2011, at 8:47 AM, Gordon Apple wrote: It’s not that I object to anyone doing it, if that makes them more comfortable, but a warning on ““” inside of “||”” is ridiculous. Everyone knows that multiplication takes precedence over addition. “” is a multiplication. “||” is, welll,

Re: Unnecessary Boolean Warning

2011-08-01 Thread Jeffrey Walton
On Mon, Aug 1, 2011 at 4:08 PM, Greg Parker gpar...@apple.com wrote: On Aug 1, 2011, at 8:47 AM, Gordon Apple wrote: It’s not that I object to anyone doing it, if that makes them more comfortable, but a warning on ““” inside of “||”” is ridiculous.  Everyone knows that multiplication takes

Re: Unnecessary Boolean Warning

2011-08-01 Thread Scott Ribe
On Aug 1, 2011, at 2:36 PM, Jeffrey Walton wrote: I wish I had a dollar for every time I lazy fingered `=` rather than `==`. And another buck for each time the compiler caught it (I use `-Wall` -Wextra` and firends). Well, firend, I believe you ;-) -- Scott Ribe scott_r...@elevated-dev.com

Unnecessary Boolean Warning

2011-07-31 Thread Gordon Apple
The following expression generates a warning message (³² within ³||²) and says to include the ³anded² expression in parens. Anybody who understands basic boolean operator precedence knows this is unnecessary. Bug report? BOOL isInUse = [super mediaIsInUse]; isInUse = isInUse || [self

Re: Unnecessary Boolean Warning

2011-07-31 Thread Gordon Apple
Sorry, that should have been posted to Xcode. On 7/31/11 3:13 PM, Gordon Apple g...@ed4u.com wrote: The following expression generates a warning message (³² within ³||²) and says to include the ³anded² expression in parens. Anybody who understands basic boolean operator precedence knows this

Re: Unnecessary Boolean Warning

2011-07-31 Thread Glenn L. Austin
On Jul 31, 2011, at 1:13 PM, Gordon Apple wrote: The following expression generates a warning message (“” within “||”) and says to include the “anded” expression in parens. Anybody who understands basic boolean operator precedence knows this is unnecessary. Bug report? BOOL isInUse =

Re: Unnecessary Boolean Warning

2011-07-31 Thread Graham Cox
On 01/08/2011, at 6:13 AM, Gordon Apple wrote: Anybody who understands basic boolean operator precedence knows this is unnecessary. True, but who does? I mean, sure, if everyone who ever sees your source has that fully committed to heart, you're golden. Otherwise, what's the harm of a few