Jason Orendorff (2013-05-10T20:29:20.000Z)
To make this a little more concrete, just for fun...

Suppose I make an object representing "all future clicks" and give it a
map() method. This much, of course, is possible already:

    var clicks = {
        map: function (f) {
            document.addEventListener("click", f);
        }
    };

With Mike's proposal, you could write:

    for (let e of clicks) {
        alert(e.clientX + ", " + e.clientY);
    }

This would desugar to:

    clicks.map(e => {
        alert(e.clientX + ", " + e.clientY);
    });

And a listener would be attached to the document. The body of the loop
would run each time the user clicked.

Iterators don't do this.

-j
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130510/8e28c07c/attachment.html>
github at esdiscuss.org (2013-07-12T02:27:22.421Z)
To make this a little more concrete, just for fun...

Suppose I make an object representing "all future clicks" and give it a
`map()` method. This much, of course, is possible already:

```js
var clicks = {
    map: function (f) {
        document.addEventListener("click", f);
    }
};
```

With Mike's proposal, you could write:

```js
for (let e of clicks) {
    alert(e.clientX + ", " + e.clientY);
}
```

This would desugar to:

```js
clicks.map(e => {
    alert(e.clientX + ", " + e.clientY);
});
```

And a listener would be attached to the document. The body of the loop
would run each time the user clicked.

Iterators don't do this.