-
Notifications
You must be signed in to change notification settings - Fork 34
should flatMap flatten iterables or iterators? #229
Comments
Flattening iterables is much more convenient than iterators. |
getting some serious deja vu from this question 😄. I guess I would ask: what are some uses we can come up with for this |
How does it currently flatten iterables? The spec steps seem to assume an iterator. |
flatMap step 3.a.vi is
and |
same for async |
gotcha - but if we removed the |
Right. You'd have to return |
That seems like a pretty large ergonomics hit. Now that I'm thinking about strings, though - currently, would i have to wrap it in |
Yes. This is arguably a reason to prefer only flattening iterators - if we flatten iterables, |
for strings, i agree with you - but for every other value, it's a huge tax :-/ |
This has already been discussed about 3 years ago: #47 (comment), and the string problem/feature in #55. |
Isn't Especially since each element yielded from an iterable |
Also, I certainly wouldn't want to exclude iterables here. I just wonder if the behavior of |
I just saw #55 (comment), but I'm not sure I agree. Strings are special, and flattening them is more than likely unintentional. |
Thanks for the pointer @bergus. I had forgotten about that thread. A significant difference between then and now is that (after #55) we are now considering a
I'm leaning toward this solution. What would be the downside of this?
|
The downside is that you shouldn't have to wrap a value in an iterator just to be able to return it from the mapper. |
Fair enough, although I don't think that decision has been brought to plenary yet, and it's a pretty big one. |
I see 4 variants there:
I think the majority agrees that d) has bad developer experience (having to wrap all iterables in |
I also think we should keep the currently specified semantics. |
It currently flattens iterables. If
X.prototype.flatMap
flattensX
s, we should instead be flattening iterators.As mentioned by @rbuckton in #117 (comment).
The text was updated successfully, but these errors were encountered: