In section 12.6.4, "The for-in statement", of the ECMA-262 spec, it says

The mechanics of enumerating the properties (step 5 in the first algorithm, 
step 6 in the second) is
implementation dependent.

I don't see anything in the spec about Array being an exception and having a 
guaranteed for-in order. So I think an Array or ArrayCollection implementation 
is free to execute a for-in loop in any order it wants.

Gordon Smith
Adobe Flex SDK Team

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Alex Harui
Sent: Thursday, December 11, 2008 11:33 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: speed of the "for each" looping

Funny.   I didn't realize we were talking about iterating arrays with for..in 
until just now.  I don't think we do that in Flex code.  If the docs say arrays 
will iterate via for..in in index order then I'd probably trust that, 
especially if you stuff your arrays in index order

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Dave Cragg
Sent: Thursday, December 11, 2008 3:08 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: speed of the "for each" looping


Could you clarify this? Does this non-guarantee apply to numerically indexed 
arrays and ArrayCollections too? Or just to associative arrays and object 
properties?

The docs imply that the order is maintained by for...in with numerically 
indexed arrays. It would be a big change if that were not the case.

Cheers
Dave

On 10 Dec 2008, at 23:00, Gordon Smith wrote:




So don't use for..in or for each... in if you care about the enumeration order. 
It could very possibly change in future versions of the Flash Player.
                                                                                
                                                                     &n! bsp;   
&nbs! p;
Gordon Smith
Adobe Flex SDK

Reply via email to