Dmitry Soshnikov (2015-02-23T18:50:03.000Z)
d at domenic.me (2015-03-06T00:50:34.937Z)
On Mon, Feb 23, 2015 at 10:09 AM, Andreas Rossberg <rossberg at google.com> wrote: > I don't see the relation to the OP's problem. It tends to break traversing by returning a special marker. The same issue exists e.g. with `forEach` method, not only `reduce`. The `reduce` seemed to me just a particular case, that's why I mentioned TCP, that could solve both. If there are actual limitations with current state of the spec (and complexities of implementations), it can be just that `@@reduced`. Though then again you'd have the case like: ```javascript $stopTraversal = {}; try { bigData.forEach((v) => { if (v > 100) { $stopTraversal._returnValue = v; throw $stopTraversal; } }); } catch (ex) { if (ex === $stopTraversal) { _data = $stopTraversal._returnValue; } } ``` If this is something more convenient than: ```javascript bigData.forEach((v) { // note, it's not an arrow, but TCP block if (v > 100) { _data = v; return; // could be `exit`; } }); ``` For the `reduce` method it could actually `return '99+'`. That's said, if the practical need exists specifically for the `reduce` function, I'm not against having "stop traversal" mechanism only there.