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
reviewing #47
Comments
do you plan to implement this proposal as (proof of concept) npm package ? |
it's already been implemented in core-js so I don't think making a separate package is needed. |
core-js isn't the entirety of the shim ecosystem - separate packages are absolutely needed - but I'll be making those once the proposal's stage 3. |
@devsnek It seems that |
the real issue is that we can't just flatten anything that happens to have a next method. I discussed this a bit in the other issue, but really Symbol.iterator is the correct interface to use here. Do you have more information on that philosophy? I feel like the stdlib is small enough that we don't necessarily have these patterns yet. |
@michaelficarra Could you link the discussion of that philosophy, please? I can't find it in the tc39-notes. |
@devsnek @bergus Not really additional context, but here's the mentions in the notes:
@domenic, @bterlson, @ljharb, and I were the major participants in that decision.
This is the argument that was used to support the iterables stance for
Could you elaborate? That doesn't make sense to me. What's the API for enumerating the contents of arbitrary "container"s? Or are you just talking about values that support some iteration API? |
@michaelficarra can you maybe share a minimal strawperson usage code of such version of flatMap to illustrate what do you mean ? |
@c69 usage of what? |
A sample of how a user would call a flatMap on a iterator and what that will return. edit:
i.e.: Iterator.flatMap( fn: (v: any,i) => Iterator|any) with a check where Symbol.Iterator for return value exists in prototype chain, and if not, then treat it as if it was 1-element long vanilla iterator. |
@c69 This proposal currently adds a
I did not suggest I knew the answers to these questions. @devsnek suggests that we've done the best we can on the latter question. |
if it makes you feel better, the most common variant of Symbol.iterator is |
Iterators are always iterable by convention (although not by contract) - this feels like a simple case where we can maximize utility without forcing users to always add an Iterator.from wrapper. |
@michaelficarra Thanks, I must have glanced over that. I always thought that supporting the heterogenous case and non-flattened string values was mostly useful for arbitrary-depth
Yes, I was referring to some enumeration interface on the value. For example, Scala's On the other hand, Java's |
perhaps we should just push flatMap to another proposal? this seems like a rather complex interface issue. |
My biggest concern is on the optimisability of |
I don't see any problems with the optimisability of that, just a standard IC at the callback site, although my knowledge of js optimisation is limited to V8. |
Scala (2.13) solves this quite elegantly, imho..
Yes, this means that our method becomes somewhat "less lazy", but in fact its only the processing of one element in the source iterator that creates an eager computation spike. p.s.: nice quote from the same page - "one should never use an iterator after calling a method on it" [except .next and .hasNext]. |
I emailed Dean a while ago and haven't heard anything back. I think we might just need to get a different reviewer. |
Any update on the review ? |
I believe we are getting close to stage 3 here, but I don't know if the reviewers are still active. Should we ask for new reviewers at the next meeting? |
@codehag I think we should. |
Tracking reviews (along with other stage 3 entrance criteria) in #117 now. |
cc @michaelficarra @dtribble
this isn't quite ready for stage 3 yet (i need to review some error behaviour), but i wanted to let y'all know pretty much all the semantics are laid out at this point. if you have any insights/criticism/etc please feel free to share them and i will try to address them when i can (i'm starting university over the next few weeks so things will be busy).
The text was updated successfully, but these errors were encountered: