Description
While writing tests for #31, I started pondering this ☝️.
For comparison, F# throws an ArgumentException
for Array.zip
and List.zip
, but not for Seq.zip
. Most likely, this is because "getting the next item" can have an unwanted side effect, so instead, they choose to stop processing as soon as one of the sequences is exhausted.
Arguably, such side effect can still happen. I.e., for zip
we have to call MoveNextAsync
, which will give us a bool
that tells us whether we reached the end of the sequence. But, if the first sequence still has items, but the second sequence is exhausted, the side effect of the first sequence for "one item past the last" has already happened.
In fact, I think the Seq.zip
in F# should probably come with a warning. What if each item is "getting a web page of several megabytes"? AFAIK, there's no peek
function that would potentially tell me, without side effects, that a sequence is exhausted.
Edit: linking the discussion in the F# repo: dotnet/fsharp#14121