[swift-evolution] [Review] SE-0094: Add sequence(initial:next:) and sequence(state:next:) to the stdlib

Erica Sadun erica at ericasadun.com
Wed May 25 15:51:22 CDT 2016


> On May 25, 2016, at 2:18 PM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
>> We think the need to do a capture is icky, so the sequence form is
>> almost always better.
> 
> I agree that the need for a capture is ugly.

>> The design of AnySequence and AnyIterator dates from a time when the
>> compiler was very immature and many design avenues we might have taken
>> were not available.  I find the `sequence` forms to be superior in
>> general, and IMO at some point we should re-evaluate the interfaces to
>> AnySequence and AnyIterator.
> 
> That sounds like a reasonable justification for keeping sequence(state:next:).
> 
> -Kevin Ballard


I think Kevin will agree that I was really slow on uptake in terms of the state version, but once
I *got* it, I found that I kept using it. Yesterday, I was showing someone some math using cubic 
Beziers, and boom there was the extra "var t = 0.0" sitting out there, which I immediately recognized 
and refactored into the sequence(state:next:) version instead. It produced a much cleaner and
more pleasing result, imo. (I also found a dandy playground bug unrelated.)

I know that the idea of an extra capture mentally feels ugly but it's really useful. A week ago, 
I wouldn't have fought to keep the option. Now, I would.

-- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160525/65587daf/attachment.html>


More information about the swift-evolution mailing list