[swift-evolution] [Pitch] Remove destructive consumption from Sequence
swift-evolution at haravikk.me
Thu Jun 30 15:17:11 CDT 2016
> On 30 Jun 2016, at 18:26, Dave Abrahams <dabrahams at apple.com> wrote:
> Q: Why should there be indices on an infinite multipass sequence?
> A: Because the operations on indices apply equally well whether the
> sequence is finite or not. Find the index of a value in the
> sequence, slice the sequence, find again, etc.
Would it not make more sense for sequences that can benefit from subscripts to just conform to Indexable? It seems like having basically all of the Collection-specific methods on Sequence too would be confusing, and dilute any nothing that these are sequences where elements are supposed to be consumed in-order, as it would give the illusion that you can skip around with the convenience of an array.
There's also the issue of how you would even index something that's potentially infinite; you'd need to use a big integer in which case you could end up with your indices growing to infinite size over time? It may not be very obvious that this could be the case.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution