This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Description
In plenary, some argued for passing a second index parameter to the Array.prototype
-like methods' callbacks. I'm not entirely opposed to this but I'm unconvinced at the moment that this is an improvement. Also, I am really uninterested in adding separate "indexed" versions of each helper, as was mentioned. Here's how I see the pros/cons of each approach.
Motivation for not passing an index
- index is not useful for lookaround indexing pattern
- besides, we will have better patterns for this that don't involve indexing, such as zipping
- indices are relative to in-progress iteration, not some indexable structure
- it's easy to change the base of these indices when introducing a
drop
/filter
/etc earlier in the chain
- avoids the common class of error that includes passing
parseInt
to Array.prototype.map
- if we don't continue passing index for non-
Array.prototype
methods (like zipWith
, takeWhile
, tap
), we create a weird divide
- matches for-of not providing a counter
- implementations don't need to keep a counter
Motivation for passing an index
- familiarity from
Array.prototype
methods
- though, no indexable third parameter passed, so easy to misuse for indexing an original indexable/iterable structure
- convenient: don't need to add an
indexed()
to the chain
- no intermediate tuples to create and GC
- 1 less method on
Iterator.prototype
/cc participants: @js-choi @waldemarhorwat @ljharb @bakkot @erights @rbuckton @littledan