for-in evaluation order

Geoffrey Sneddon gsneddon at
Tue Dec 28 03:59:44 PST 2010

On 27/12/10 13:40, Andreas Gal wrote:
> I can't speak for other VM implementors, but I think most
> implementors will not want to guarantee either enumeration method
> (property addition order vs numeric order). In some cases we store
> array data "dense", in others we punt and use a natural object
> representation. The decision when we switch between representations
> is a brittle heuristics. Allowing the underlying representation and
> along with it the enumeration order to bleed through is faster than
> normalizing (which in some cases would mean sorting property indexed
> names).

Both Carakan and V8 use numeric order for all uint32-named properties 
for all objects (even when sparse), and simply avoid using any 
heuristics at all by never changing between the two. This does cause 
some breakage, but currently neither ourselves nor V8 intend on changing 
to insertion order, preferring to use evangelism for what does break.

[1] is the V8 bug for the behaviour; looking through then duplicates we 
have of the bug we have for our behaviour, almost all duplicates are 
bugs reported by web developers, not site-compatibility bugs.


Geoffrey Sneddon — Opera Software

More information about the es-discuss mailing list