On 23/06/2009, at 10:03 PM, Igor Mozolevsky wrote:

BOOL someValue = [object returnsBool] | [anotherObject alsoReturnsBool];

which is a bitwise OR of two YESes, essentially.


OK, makes sense... and since ||= is not valid, there should be no hidden gotcha with organising things this way.

I was running into a problem with short-circuit evaluation with BOOL foo = [a bar] || [b baz]; where baz wasn't being called. Splitting the code down to

BOOL foo = [a bar] | [b baz]; will always call baz but the result <foo> will be identical...

The problem crops up in combining calls to -validateMenuItem:, where the validation not only returns YES or NO but may also have side effects like changing the state of item. The call must be made even if the actual result is logically redundant.

--Graham
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to