[swift-evolution] [Pitch] Remove destructive consumption from Sequence
Jonathan Hull
jhull at gbis.com
Tue Jun 28 13:31:39 CDT 2016
> On Jun 28, 2016, at 10:51 AM, Dave Abrahams <dabrahams at apple.com> wrote:
>
>>> 1. Presumably these are all for-in-able. What makes something
>>> for-in-able?
>>
>> I would think the potentially infinite should require for-in-until
>> (even if you explicitly set until to false to create an infinite
>> loop), but collection would allow for-in (with optional until). That
>> way you have to acknowledge the possibility of an infinite
>> sequence/iterator.
>
> Are you proposing a new language feature? We could also do this with
>
> for i in allIntegers.until(isPrime)
I was, but I think I would be ok with this too, as long as the compiler caught the issue and suggested a fix. The key is that we are forced to deal with the possibility of an infinite sequence/iterator. Also:
for i in infSequence.maxLoops(3000) //or a better name for this idea
Thanks,
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160628/ee0985fe/attachment.html>
More information about the swift-evolution
mailing list