[swift-evolution] [Pitch] Remove destructive consumption from Sequence
dabrahams at apple.com
Sun Jun 26 09:02:24 CDT 2016
on Wed Jun 22 2016, David Waite <david-AT-alkaline-solutions.com> wrote:
>> On Jun 22, 2016, at 2:57 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> <Ahem> “Iterators,” please.
> That makes me happy - for some reason I thought it was still GeneratorProtocol
>>> destructively, but such Generators would not conform to the needs of
>>> Sequence. As such, the most significant impact would be the inability
>>> to use such Generators in a for..in loop,
>> Trying to evaluate this statement, it's clear we're missing lots of
>> detail here:
>> * Would you remove Sequence?
>> * If so, what Protocol would embody “for...in-able?”
> No, I would just remove the allowance in the documentation and API
> design for a destructive/consuming iteration. Sequence would be the
> interface to getting access to repeatable iteration, without the need
> for meeting the other requirements for Collection.
That would be wrong unless there exist substantial examples of a
multipass Sequence that *can't* meet the other requirements of
Collection without loss of efficiency. And since I can write an adaptor
that turns any multipass sequence into a Collection, I think it's
trivial to prove that no such examples exist.
More information about the swift-evolution