Property Iteration in JSON serialization

Brendan Eich brendan at mozilla.com
Wed Oct 14 22:26:16 PDT 2009


On Oct 14, 2009, at 7:01 PM, Allen Wirfs-Brock wrote:

> Similarly, rather than trying to fully specifying for-in enumeration  
> order (and invariably causing potentially breaking changes for some  
> implementations)

I'm focusing on your parenthetical aside: we have precedent in Harmony  
(functions in blocks) for finding room to create a better standard  
where browsers do not agree, and therefore unless browser detection is  
going on, cross-platform JS on the web cannot depend on the  
intersection semantics (the empty set).

I think we should investigate breaking changes. The IE JScript  
deviations document linked from

http://wiki.ecmascript.org/doku.php?id=es3.1:es3.x_working_docs&s=jscript+deviations

contains some amazing details of IE"s for-in behavior:

* Enumerate properties on immediate prototype in reverse order (w.r.t  
the order in which they were added)

* Enumerate properties in-order on rest of the objects on the  
prototype chain

* Enumerate properties in-order on present object.

Reverse insertion order on the immediate prototype properties, not  
something other engines do.

Array element enumeration details are lacking, but again if the  
observation that array elements are almost always created in index  
order, then insertion order == index order. The exceptions may or may  
not work as expected on insertion-order-only implementations. Firefox  
3+ uses index order. We're not receiving bug reports.

There's room to find a better common semantics here, it seems to me.

/be


More information about the es-discuss mailing list