[swift-evolution] [Pitch] Remove destructive consumption from Sequence

Haravikk swift-evolution at haravikk.me
Fri Jul 1 02:34:03 CDT 2016


> On 30 Jun 2016, at 23:39, Dave Abrahams <dabrahams at apple.com> wrote:
> All multi-pass sequences can benefit from subscripts.

Sorry, not really what I meant, but rather; how many sequences are really going to use them?

> It's trivial; the index contains the iteration state.  The only
> fundamental difference between the constraints on Iterator and the
> constraints on an Index is that Iterator doesn't support comparison for
> equality.

Won't this make implementing sequences more complex? Sequences are currently dead easy to implement, and to implement in an ad-hoc way via AnySequence(body:), how would that be done under this required indexing scheme? I just feel like things are easiest if Sequence is simply tweaked to require that it's iterators must be non-destructive, as implementing them will be just as easy, at which point it's just a matter of separating out which methods take Sequences and which take Iterators.


More information about the swift-evolution mailing list