Member Ordering

Lars Hansen lhansen at
Wed Jun 4 10:52:58 PDT 2008

(Bringing back cross-posting to es4-discuss.)

Why should Array objects be treated specially?  I can't 
speak to the current internals of Opera, but I know that
in the past it segregated named and numbered properties,
independently of the type of the Object, and enumeration
of properties did not depend on the type of object.  That
seems like a feature.

ES4 'vector' won't behave anything like this.  The current
spec says that the default iterator for vector enumerates
properties in the range 0 .. length-1 in that order and
skips prototype properties and all named properties.  
Programmers who want to enumerate those have to create a
custom Enumerator object.

We also believe that the right thing is to provide some
facilities on Array objects so that for-in loops can be
used to iterate across numbered properties only, eg, a
'range' property that delivers a suitable iterator.  But
some details remain unsettled.

It's possible that the uniform thing to do would be for
enumeration to work the same on vector as on Array, and for
there to be a 'range' property on vector to deliver the
sane iterator.  But IMO the Array behavior is broken and
would be changed, were it not for backward compatibility


> -----Original Message-----
> From: Mark S. Miller [mailto:erights at] 
> Sent: 4. juni 2008 17:59
> To: Douglas Crockford
> Cc: Lars Hansen; es3.x-discuss at; brendan at
> Subject: Re: Member Ordering
> On Wed, Jun 4, 2008 at 8:42 AM, Douglas Crockford 
> <douglas at> wrote:
> > That is indeed discouraging. Perhaps ES3 did the right thing by 
> > leaving the order unspecified.
> No. Please specify some deterministic order. I don't much care which.
> But leaving it unspecified complicates testing unnecessarily.
> Also, please see <>
> (draft paper) for further benefits that can only be realized 
> after removing such unavoidable sources of hidden 
> non-determinism. (Brendan, I've added you to the cc to make 
> sure you see this paper. It makes another interesting bridge 
> between information-flow and ocaps.)
> A proposal:
> * For direct instances of Array: Use the Opera ordering for 
> the own properties. Then the normal prototype-following 
> insertion order for ascending the superclass chain. Note that 
> Array.prototype is not an instance of Array, and so should 
> enumerate by insertion order.
> * For all other objects, even those that fancy themselves to 
> be Array-like, Use pure prototype-following insertion order. 
> I.e., insertion order of the own properties, then insertion 
> order of its prototype, etc...
> Regarding ES4 numerically indexable collections (Vector?) -- 
> it's up to you guys, but I'd recommend Opera ordering.
> If this proposal isn't good for some reason, reject it. But 
> please specify something deterministic!
> -- 
>     Cheers,
>     --MarkM

More information about the Es4-discuss mailing list