On Tuesday, 9 June 2020 at 23:53:16 UTC, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a
thing
Someone already mentioned dictionary.
Consider that most ranges don't actually have an index. In this
case you aren't actually asking to add indexes, but a count of
iteration.
For those ranges which do have indexing, what if the range is
iterating from a location in the middle. Now you have an
iteration count but not the true index. `enumerate` allows for
specifying a starting number but this still isn't sufficient
since a filter could easily jump to any index.
Now none of this may come as a surprise to you, but having an
iteration counter and an array index using the same api does open
the door for confusion.