Oh you are right, I totally missed that, thanks.

> On May 10, 2016, at 12:10 PM, Xiaodi Wu <[email protected]> wrote:
> 
> Nicholas wrote that he would like `while true` to be a compile-time error. 
> I'm curious as to why.
> 
> On Tue, May 10, 2016 at 13:47 Tyler Cloutier <[email protected]> wrote:
>>> On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution 
>>> <[email protected]> wrote:
>>> 
>>>> On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution 
>>>> <[email protected]> wrote:
>>>> Swift Evolution Community,
>>>> 
>>>> Currently writing an infinite loop in swift looks either something like 
>>>> this:
>>>> 
>>>>     while true {
>>>>         if ... { break }
>>>>         //...
>>>>     }
>>>> 
>>>> Or this:
>>>> 
>>>>     repeat {
>>>>         if ... { break }
>>>>         //...
>>>>     } while true
>>>> 
>>>> But I think it might be best to change the syntax / behaviour of `repeat` 
>>>> to loop 
>>>> indefinitely if no trailing while clause is present:
>>>> 
>>>>     repeat {
>>>>         if ... { break }
>>>>         //...
>>>>     }
>>>> 
>>>> while still allowing a trailing `while` clause as in:
>>>> 
>>>>     repeat { 
>>>>         foo += bar
>>>>     } while foo.count < limit 
>>>  
>>> What is your motivation for this change?
>>>  
>>>> I also want to propose that it should be a compile time error to use 
>>>> single `Bool` constants as while loop conditions, so no more `while true { 
>>>> ... }` it would become `repeat { ... }`
>>> 
>>> What problems are solved by forbidding `while true`?
>> 
>> I don’t think the proposal is forbidding it, but rather making it optional. 
>> So that 
>> 
>> repeat {
>> 
>> } 
>> 
>> is equivalent to 
>> 
>> repeat {
>> 
>> } while true
>> 
>>>  
>>>> I was thinking of drafting a short proposal if there was enough positive 
>>>> feedback. 
>>>> 
>>>> How does it sound?
>>>> 
>>>> - Nick 
>>>> 
>>>> _______________________________________________
>>>> 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
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to