[swift-evolution] [Proposal] Change guarantee for GeneratorType.next() to always return nil past end
Dave Abrahams
dabrahams at apple.com
Sat Mar 5 23:15:18 CST 2016
on Sat Mar 05 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:
>> In fact, I don't think the post-nil behavior of generators is even
>> the biggest potential gotcha. A much bigger issue is how generators
>> behave when you make copies of them. If you ever copy a generator
>> you're supposed to never touch the original again, but it's easy to
>> violate that accidentally, and most generators actually behave
>> sanely when copied anyway.
>
> That's true, but it's just not addressable until we have some kind of
> borrowing system in place.
I know this is veering off-topic, but I don't know if that can
fix this issue in Swift. I very much doubt we're going to want to
create a world that has non-copyable types, and that's really what you
need to make this issue go away. Or, you can decree that every
generator is a reference type.
--
-Dave
More information about the swift-evolution
mailing list