> On Jun 28, 2016, at 2:18 PM, Jonathan Hull via swift-evolution 
> <[email protected]> wrote:
> 
> One more question on this.
> 
> How would we handle the opt-out safety for people who are intentionally 
> trying to create an infinite loop?
> 
> I don’t think we can make .until() safely lazy for iterators which have 
> reference semantics and are destructive single-pass, so it has to be eager.  
> If .until() is eager, then .until(false) will fall into an infinite loop 
> before the for-in loop is even run.  

This is an argument against a library solution if iterators have reference 
semantics.  Any solution that requires eager behavior is not a good solution.

> 
> Maybe there just a way to plug an iterator/sequence directly in, and then 
> silence the warning?  or we could do for-in-until…
 
I don’t think this should be a warning that can be silenced.  I think you are 
uncovering good reasons to go with a language supported solution.

This wouldn’t need to happen in Swift 3.  There have been other cases where we 
have adopted a “break it now in anticipation of making it better in the future” 
policy.  If we conclude that a language solution is warranted and can’t get it 
into Swift 3 that is ok IMO.  It is still possible to manually iterate infinite 
sequences.  This wouldn’t be that big a deal given that it is relatively 
infrequent.

> 
> Thanks,
> Jon
> 
>> On Jun 28, 2016, at 10:51 AM, Dave Abrahams <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>>>> 
>>>> This is a reasonable structure, but there are important details missing.
>>>> 
>>>> 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)
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to