Re: Very interesting ordering caveat with NSArray arrayWithObjects:
Re: Very interesting ordering caveat with NSArray arrayWithObjects:
- Subject: Re: Very interesting ordering caveat with NSArray arrayWithObjects:
- From: Uli Kusterer <email@hidden>
- Date: Sun, 5 Apr 2009 18:02:51 +0200
On 04.04.2009, at 02:30, Eric Hermanson wrote:
Now, one would expect that the array would contain:
element 1: MyCounterInstance.oid=1
element 2: MyCounterInstance.oid=2
However, this is NOT the case. Either the compiler or the runtime
executes the SECOND call to [MyCounterClass newObject] FIRST, so the
array actually contains:
element 1: MyCounterInstance.oid=2
element 2: MyCounterInstance.oid=1
Nothing to do with ObjC or NSArray. That's a part of the C standard
left open to allow platform-specific optimizations. I've blogged about
it in a simpler context here:
http://zathras.de/blog-c-parameter-evaluation-order.htm
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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