On Sun, Feb 22, 2015 at 10:11 PM, Domenic Denicola <[email protected]> wrote:

>  My initial feedback is that this needs a lot more "why" in comparison to
> the "how".
>

The technical reason for this I guess, is that JS doesn't have TCP blocks,
that would allow you to stop iteration, and exit the `reduce` context right
from the callback context. With TCP it would be a `return` statement, which
in JS we have to solve throwing a special "marker" exception, which should
be caught and analyzed.

>From the practical perspective, yeah, it would be good to see real examples
of how useful the feature is. Of course if we take the reason: "exit from
an hight-order iteration as soon as possible in a convenient way", that
could sound reasonable/practical. Although, to have concrete examples would
be good.

However, I'd say, JS betters needs some sort of TCP blocks, which would
solve other similar cases (and which I'm pretty sure were discussed several
times couple of years ago). E.g. in Ruby that example would be much easier,
and that `@@reduced` would be just simple intuitive `return`.

Dmitry



> The only inkling of why this might be useful is an unsourced assertion
> that it's done in Clojure, for unknown reasons. The example code isn't very
> compelling either; something more real-world would be good there.
>  ------------------------------
> From: Lee Byron <[email protected]>
> Sent: ‎2015-‎02-‎23 00:58
> To: [email protected]
> Subject: short-circuiting Array.prototype.reduce
>
>  Hey all,
>
>  I’d like to propose an addition to ES7 to add @@reduced as a way to
> short-circuit from Array.prototype.reduce.
>
>  I’ve written up a polyfill and explanation here:
>
>  https://github.com/leebyron/ecma-reduced
>
>  I would love your feedback on this.
>
>  Lee
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to