Day 2 meeting notes

felix felix8a at
Fri Jul 30 21:06:17 PDT 2010

On 7/30/10 14:56, Brendan Eich wrote:
> On Jul 30, 2010, at 2:47 PM, felix wrote:
>> On 7/30/10 14:37, Brendan Eich wrote:
>>> For Harmony, we do not propose to standardize |for each|. Instead, the iteration and array comprehensions proposals for Harmony (see the wiki) propose that programmers choose keys, values, items (properties), or other iteration protocols by saying what they mean more precisely on the right-hand side of 'in':
>>> for (k in keys(o)) ...
>>> for (v in values(o)) ...
>>> for ([k, v] in properties(o)) ... // Python's "items"
>>> This seems better in TC39 members' views than adding ambiguous 'each' as a contextual keyword.
>> I'm wary of that because this looks to me confusing:
>>    a = keys(o);
>>    for (k in a) ...
> The confusion here seems to be assuming that |a| is an Array instance. It's not. It is an iterator, so you'll get the keys (property names) found in o -- you won't get 0, 1, ... a.length-1.
> To avoid this confusion you can add new syntax (|for each| or whatever, doesn't matter). I've argued in recent posts that it is better from a global and long-term point of view to reform for-in after Python, than to condemn it and grow the language with new and generally more verbose, yet similar, syntax.

I should have used a letter other than 'a'.  my expectation from current 
javascript is that 'a' is an object, and that 'for (k in a)' will 
iterate over the object's properties.

it seems odd to me that if 'a' is an iterator, it will iterate over the 
iterator's value stream instead of the iterator's properties, unless you 
define the two to be identical, which would be strange.  eg, if you have 
an input stream iterator f, would f.hasOwnProperty('bacon') work or not?

yes, I'd like generalized iterators like python, so this is not really 
an argument.

More information about the es-discuss mailing list