Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-05 Thread Uli Kusterer
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 [MyCounterCla

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-05 Thread Jean-Daniel Dupas
This is not the var arg, it append with all functions (on Intel Mac). Evaluation order in argument passing is undefined. Someone in this thread (Mike IIRC) quoted the sentence in the C standard that states this. Le 4 avr. 09 à 08:14, Eric Hermanson a écrit : A comma is a sequence yet the o

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-04 Thread Eric Hermanson
A comma is a sequence yet the order in arrayWithObjects is indeterminate. It must be the var arg causing the ordering mix. Sent from my iPhone On Apr 4, 2009, at 12:29 AM, Michael Ash wrote: On Fri, Apr 3, 2009 at 8:30 PM, Eric Hermanson wrote: Some (or most) people might be aware of thi

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-04 Thread Michael Ash
On Sat, Apr 4, 2009 at 2:14 AM, Eric Hermanson wrote: > A comma is a sequence yet the order in arrayWithObjects is indeterminate. >  It must be the var arg causing the ordering mix. No, the comma *operator* is a sequence point. In other words, if you just write "foo(), bar();", then the order is

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-04 Thread Sherm Pendley
On Fri, Apr 3, 2009 at 8:30 PM, Eric Hermanson wrote: [MyCounterClass newObject] is a static method that returns a new > autoreleased instance A method that begins with the word "new" is supposed to return an object that you own. See: < http://developer.apple.com/documentation/Cocoa/Concep

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-04 Thread Gregory Weston
Eric Hermanson wrote: Some (or most) people might be aware of this caveat, but I was not, so I'll share it. Consider this code: NSArray *array = [NSArray arrayWithObjects:[MyCounterClass newObject], [MyCounterClass newObject], nil]; where [MyCounterClass newObject] is a static method that

Re: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 8:30 PM, Eric Hermanson wrote: > Some (or most) people might be aware of this caveat, but I was not, so I'll > share it. > > Consider this code: > >    NSArray *array = [NSArray arrayWithObjects:[MyCounterClass newObject], > [MyCounterClass newObject], nil]; > > where [MyCou