Property Iteration in JSON serialization

Brendan Eich brendan at mozilla.com
Wed Oct 14 10:18:51 PDT 2009


We talked about requiring it. It's a de-facto standard, followed for  
direct ("own") properties of most objects. Exceptions may include  
arrays (possibly only dense) and host object (of course)!

I'm committed to helping ensure we get better for-in specification --  
and meta-programming -- in Harmony. For now the de-facto standard of  
for-in enumerating in insertion order is pretty strong without a de- 
jure spec.

/be

On Oct 14, 2009, at 9:27 AM, Brian Kardell wrote:

> On Wed, Oct 14, 2009 at 5:41 AM, Patrick Mueller <pmuellr at yahoo.com>  
> wrote:
>> On Oct 14, 2009, at 2:42 AM, Oliver Hunt wrote:
>>
>>> All ES implementations are required to enumerate object properties  
>>> in the
>>> order of insertion, regardless of internal representation, and the  
>>> JSON
>>> object definition defines the replacer execution in terms of that  
>>> standard
>>> object enumeration.
>>
>> I understand that's what all (or most) of the implementations  
>> actually do,
>> but the ES5 spec I'm looking at - Ecma/TC39/2009/043 - doesn't  
>> actually say
>> it's required.
>>
>> In 12.6.4 discussing the for-in statement, it says: "The mechanics  
>> and order
>> of enumerating the properties (step 6.a in the first algorithm,  
>> step 7.a in
>> the second) is not specified."
>>
>> In 15.2.3.14 discussion Object.keys(), it says: "If an implementation
>> defines a specific order of enumeration for the for-in statement,  
>> that same
>> enumeration order must be used in step 5 of this algorithm."
>>
>> In 15.12.2 discussing JSON.parse(), it says: "The ordering of the  
>> Strings
>> should be the same as that used by the Object.keys standard built-in
>> function."
>>
>> In 15.12.3 discussing JSON.stringify(), it says: "The ordering of the
>> Strings should be the same as that used by the Object.keys standard  
>> built-in
>> function."
>>
>> Sorry, property ordering is an unfortunate pet peeve of mine.  :-)
>>
>> Patrick Mueller - http://muellerware.org/
>>
>>
>
> Uh oh... Patrick looking at the same parts as me reacting the same way
> (I believe older pre-5 docs also said something similar)...
> When Oliver said "All ES implementations are required to..." I assumed
> that I missed something in the new 5 docs - not that everyone just
> seems to have implemented roughly the same thing...
>
> Is it required - or is it not?
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list