Re: Unnecessary Boolean Warning
Re: Unnecessary Boolean Warning
- Subject: Re: Unnecessary Boolean Warning
- From: Graham Cox <email@hidden>
- Date: Thu, 04 Aug 2011 10:56:17 +1000
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 about that. While this optimisation is to be expected, the order of execution (left to right) and the optimisation (b not executed) is implementation dependent.
This is a classic question for coding job interviews.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden