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.  

Maybe there just a way to plug an iterator/sequence directly in, and then 
silence the warning?  or we could do for-in-until...

Thanks,
Jon

> On Jun 28, 2016, at 10:51 AM, Dave Abrahams <[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

Reply via email to