Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can iterators be pretty and immutable? #504

Closed
tomek-he-him opened this issue Sep 10, 2015 · 2 comments
Closed

Can iterators be pretty and immutable? #504

tomek-he-him opened this issue Sep 10, 2015 · 2 comments

Comments

@tomek-he-him
Copy link
Contributor

I hope to start a discussion about 11.1.

I bet you know trine. The whole concept of the lib is based on iterators – to have a unified set of functions working with any sort of collection. It looks very elegant and “native” to JS:

const characters = strings
    ::map(String.prototype.split::partial(""))
    ::reduce(Array.prototype.concat)
    .sort()
    ::uniq();

👍 Using iterators this way doesn’t involve managing state, except when writing the utilies.

👍 There’s no risk of mutating stuff. Every function is returns a new iterator.

👍 One more bonus – the thing is lazy. So you can map over infinite collections, etc. Lots of functional programming goodness.

👎 There’s one “but”. Working with iterators in such an elegant way is only possible with the function bind syntax. And that doesn’t come into the spec until ES 2016 (if at all). They do transpile cleanly to ES5 with babel though.

@goatslacker
Copy link
Collaborator

We don't use trine and have no plans to use trine in the near future.

But 👍 to trine in general IMO.

@ljharb
Copy link
Collaborator

ljharb commented Dec 24, 2015

For now, given our non-use of trine, and the function bind syntax's stage 0 status, I'm going to close this.

As either of these changes, we can re-evaluate this section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants