On May 8, 2013, at 11:16 AM, Gareth Smith wrote:

> ...
> 
> An alternative reading of the specification is that we are interested in
> property /names/, not properties. Given this reading, in both examples a
> property named 'x' was always reachable from a, so it must be enumerated
> in both examples. Is this second reading closer to the intent of the
> specification? I note that the current wording of the spec talks about
> "properties" when things are being added and deleted, and "property
> names" only when talking about duplicate enumerations.


On May 9, 2013, at 4:58 AM, Andreas Rossberg wrote:

> ...
> 
> As for your other question, yeah, I think that "property" and
> "property with name" are used interchangeably in those parts of the
> spec.
> 

My re-reading of of the ES5 language reconfirms that the distinct use of 
property and property name is very deliberate.  Let me know if any particular 
phrases seem ambiguous to you.  
Where I think the language is somewhat sloppy is in making a distinction being 
the examination of a property by the algorithm and exposing the name of a 
property to user code.  "Visiting" might mean either of these depending upon 
the surrounding context.

One requirement that we agreed upon in the ES5 days was that a particular 
for-in loop should process any property name at most once. This was agreed upon 
even though we knew that some existing implementations violated  that 
requirement in some scenarios.  The language "A property name must not be 
visited more than once in any enumeration." was added as the statement of that 
requirement.  the use of "property name" was very deliberate in that context.

We also agreed that if a non-enumerable property of a particular name is 
encountered, then that name will not be "visited" even if it is encountered for 
an enumerable property higher on the prototype change. My interpretation of 
that requirement is that it even extends to the case where the non-enumerable 
property is subsequently deleted and then a enumerable property of the same 
name is added to a prototype that has not yet been examined.  Once a name has 
been determined to be non-enumerable, that determination can not change during 
an enumeration.

I've created an ES6 generator that I believe conforms to the intent of the ES5 
spec: https://gist.github.com/allenwb/5548164 
It is also permitted (not not required) to use an algorithm that was more 
aggressive about finding and yielding new property names that are added during 
the lifetime of the generator. 

Allen


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to