On Sat, Apr 4, 2009 at 2:14 AM, Eric Hermanson <[email protected]> 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 defined. But when you call a function you are not using the comma operator. Yes, it is the same character, but it's in a different context. And there, the comma is not a sequence point, so the order of evaluation of the different function argument expressions is completely undefined. Nothing to do with varargs, you'll find the same thing happening with any function or method. The comp.lang.c FAQ has a question addressing exactly this: http://c-faq.com/expr/comma.html It says, "The comma operator does guarantee left-to-right evaluation, but the commas separating the arguments in a function call are not comma operators." I highly encourage everybody reading this mailing list to read through that entire FAQ. C has a lot of behaviors that are not exactly obvious, and forewarned is forearmed. Mike _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
