tc39 / proposal-iterator-helpers

Methods for working with iterators in ECMAScript
https://tc39.es/proposal-iterator-helpers
1.33k stars 34 forks source link

renaming `take` #270

Closed bakkot closed 1 year ago

bakkot commented 1 year ago

Per discussion in this thread, some users infer/want that you can take multiple times from the iterator to get multiple chunks. But because exhausting the take subiterator closes the underlying iterator, you can't actually do that. That may be confusing if you're used to e.g. rust iterators.

We should probably rename it. My preference is to use limit, which is what Java calls it.

(And while we're at it we will probably want to rename drop to skip, since take is always paired with drop and limit with skip.)

Do read the discussion in the original thread. I wanted to open a separate issue so we could track it properly. cc @benjamingr

michaelficarra commented 1 year ago

The committee decided today to not go through with the rename of take and/or drop. Closing.

jmagaram commented 1 year ago

Just adding my thoughts here as I write a library for ReScript. take is not clear - didn't realize it until I thought about it and looked at other libraries. Is it takeAtLeast, takeExactly, or takeAtMost? F# calls it truncate which is more accurate unless you plan to throw exceptions if there aren't enough items. They have a take that throws exceptions.

benjamingr commented 1 year ago

@jmagaram yeah the committee isn't great at making amendments and taking feedback once a proposal is past stage 2 unless "political force" is applied and that's expensive.

From my perspective - the fact it's confusing and a (clear IMO) mistake isn't enough reason to do anything that will block this proposal since I need/want the 99% other stuff in it.