Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-11 Thread Nicholas Maccharoli via swift-evolution
Yeah after going though this thread again modifying the repeat keyword
seems like overkill.

while true { } isn't broken but I really like Ruby's loop { ... } keyword.

but adding a new loop type to swift just for replacing a special case of
the while loop also seems like a little too much.

If there isn't a strong argument for adding a loop keyword then I guess
this thread is at it's end for now.

Thanks for the feedback!

- Nick


2016年5月12日木曜日、Chris Lattner via swift-evolutionさんは書きました:

>
> > On May 10, 2016, at 6:11 PM, Tyler Cloutier  > wrote:
> >
> >
> >> On May 10, 2016, at 5:56 PM, Chris Lattner  > wrote:
> >>
> >>
> >>> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution <
> swift-evolution@swift.org > wrote:
> >>>
> >>> I agree that repeat { } is ambiguous because you have to look to the
> end for a while clause to determine if it's infinite or not.
> >>
> >> Right, this is the downside that I see with “repeat {}”.
> >
> >
> > Not to beat a dead horse, but isn’t this also true of
> >
> > repeat { ...
>
> > while true { …
>
> No, because today you always know that repeat has a condition, and that
> while does not.  That’s the point.
>
>
> >> Another option is to make it a statement modifier, which wouldn’t
> require taking it as a keyword (but also doesn’t read as well):
> >>
> >> forever repeat { }
> >>
> >>
> >> Personally, I don’t see this as a big enough improvement over “while
> true” to be worth introducing complexity for.
> >>
> >
> > If you are referring to “forever", I also don’t think that adding a new
> keyword is an improvement over “while true”.
>
> I agree.  Even if it didn’t take a keyword, Idon’t think that “repeat
> forever” is worth adding over “while true”.
>
> -Chris
> ___
> swift-evolution mailing list
> swift-evolution@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution
>


-- 

All the best,

Nicholas

Linked in:
http://lnkd.in/328U22
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-11 Thread Chris Lattner via swift-evolution

> On May 10, 2016, at 6:11 PM, Tyler Cloutier  wrote:
> 
> 
>> On May 10, 2016, at 5:56 PM, Chris Lattner  wrote:
>> 
>> 
>>> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution 
>>>  wrote:
>>> 
>>> I agree that repeat { } is ambiguous because you have to look to the end 
>>> for a while clause to determine if it's infinite or not.
>> 
>> Right, this is the downside that I see with “repeat {}”.
> 
> 
> Not to beat a dead horse, but isn’t this also true of 
> 
> repeat { ...

> while true { …

No, because today you always know that repeat has a condition, and that while 
does not.  That’s the point.


>> Another option is to make it a statement modifier, which wouldn’t require 
>> taking it as a keyword (but also doesn’t read as well):
>> 
>> forever repeat { }
>> 
>> 
>> Personally, I don’t see this as a big enough improvement over “while true” 
>> to be worth introducing complexity for. 
>> 
> 
> If you are referring to “forever", I also don’t think that adding a new 
> keyword is an improvement over “while true”.

I agree.  Even if it didn’t take a keyword, Idon’t think that “repeat forever” 
is worth adding over “while true”.

-Chris
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-11 Thread Jeremy Pereira via swift-evolution

> On 10 May 2016, at 22:27, Tyler Cloutier via swift-evolution 
>  wrote:
> 
>> 
> And isn’t this the point really. Yes there are many different ways of doing 
> something, but there should be one obvious way. IMHO, there is nothing more 
> obvious than just 
> 
> repeat {
> 
> }

Yes there is:

while true {

}

is more obvious than repeat { … }

In the first case, the fact that it is a “loop forever” is obvious right there 
at the beginning of the loop. In the second case, you have to seek out the end 
of the loop to find out that the loop will repeat forever. And it might not be 
easy to find the correct bare closing brace in a sea of closing braces in a 
complexly structured program.


> 
> It’s very clear. It’s not about adding complex control flow, it’s about 
> simplifying current syntax. I don’t think anyone is arguing that it’s more 
> powerful than what while loops currently offer.

I don’t think it simplifies the syntax, it adds an extra distinct version of 
the repeat loop. That’s not simplifying.

> 
> 

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-11 Thread Dany St-Amant via swift-evolution

> On May 10, 2016, at 9:11 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> 
> 
>> On May 10, 2016, at 5:56 PM, Chris Lattner  wrote:
>> 
>> 
>>> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution 
>>>  wrote:
>>> 
>>> I agree that repeat { } is ambiguous because you have to look to the end 
>>> for a while clause to determine if it's infinite or not.
>> 
>> Right, this is the downside that I see with “repeat {}”.
> 
> 
> Not to beat a dead horse, but isn’t this also true of 
> 
> repeat {
> 
> } while true
> 
> and 
> 
> while true {
> ...
> ...
> if condition {
>  break
> }
> }

In all the code I ever seen, infinite loop are seldom really forever, they must 
exit one day mainly for graceful exit of the application. So break statement 
are to be expected in all infinite loop. The question of the readability of a 
infinite loop is not about whether or not the loop can exit, but about the 
intent or goal of the loop. Here the 'while true' strongly advertise up front 
that the loop is to run as long as it can; while for the 'repeat', one must go 
to the end to get that intent. So for readable code, a forever loop should 
preferably  be written as:

while true { /* multi-line work */ }

And never as:

repeat { /* multi-line work */ } while true

Removing the trailing 'while true' of the 'repeat' does not help with reading 
and quickly understanding the code, for that to occurs a keyword will need to 
be added to the repeat itself; like the 'repeat forever' which is longer than 
the plain good old 'while true' at the top.

Dany

>> 
>>> while true { } is preferable in that regard, but a compromise that I saw 
>>> mentioned is:
>>> 
>>> repeat forever { }
>> 
>> This would require taking “forever” as a keyword if we supported “repeat N 
>> {", something we wouldn’t want to do.
>> 
>> Another option is to make it a statement modifier, which wouldn’t require 
>> taking it as a keyword (but also doesn’t read as well):
>> 
>> forever repeat { }
>> 
>> 
>> Personally, I don’t see this as a big enough improvement over “while true” 
>> to be worth introducing complexity for.
> 
> If you are referring to “forever", I also don’t think that adding a new 
> keyword is an improvement over “while true”.
> 
>> -Chris
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Nicholas Maccharoli via swift-evolution
Hello ​Swift Evolution community,​

Thank you so much for all the important feedback, this thread became more
lively than I initially hoped for!

First let me address Xiaodi Wu's questions from earlier:

What is your motivation for this change?


After thinking about it maybe I overreacted with wanting to phase out
`while true`.
I know `while true` is a programming idiom found in most languages but I
personally think expressions testing a single `Bool` literal
like `while true { ... }` are just as tasteless as directly using `true` as
in `if true { ... }` and might possibly signify that swift needs a better
construct to express an infinite loop.

So after reading this thread's feedback I'm changing my tone and think we
should leave `while true` alone and let it continue to be
a valid way of expressing an infinite loop but maybe at the same time we
should think of adding a more Swifty alternative.

As a source of inspiration I really like rust's solution of `loop { ... }`:
https://doc.rust-lang.org/book/loops.html
but Swift already has a `repeat` statement so I initially thought of
modifying the behaviour of `repeat` to allow omitting the trailing `while
true` as to not bloat Swift with a new keyword.

What problems are solved by forbidding `while true`?


​As I said above, after thinking about it again I think we should keep
`while true` but I want to talk about a possible issue with the
`while true` idiom:

​​
let foo: Int
​
​
while true { foo = 5; break }
​​
print(foo)

​The above code will error out with the message "Constant 'foo' used before
being initialized"​
`while true` will always enter the body of the loop at least once but since
`while` is a conditional statement this error occurs
whereas this code works just fine:

let foo: Int
repeat { foo = 5; break } while true
print(foo)

since `repeat` will unconditionally enter the repeat block at least once.
So I think my initial idea can be broken up into two distinct parts.

Part I: add a `while true` alternative


So for the `while true` idiom replacement I want to propose adding
something like a `loop { }` construct or possibly modifying the `repeat`
keyword to take a statement modifier such as `sustained repeat { ... }`


Part II: change `repeat` statement ordering OR  `while` statement modifier


Idea #1:

Add a statement modifier to `while` that would ignore the `while` loop's
condition only
on the first run-through.
Not too sure on the naming of the statement modifier but maybe something
something like `after while foo > bar { ... }`

`after` would signify that the while loops condition would be checked only
after the first iteration.

Idea #2:

change `repeat { ... } while ...` to `repeat while ... { ... }` so that the
loop condition can be seen upfront in long blocks,
adding a `repeat` in front of the while loop would ensure that the loop
runs once before evaluating the loop condition.
This would essentially remove the repeat keyword and make it a statement
modifier like the above written `after`.

Sorry for dragging this out a little after all the great feedback but does
either idea have any appeal to the Swift community?

Thanks!

- Nick












All the best,

Nicholas

Linked in:
http://lnkd.in/328U22


On Tue, May 10, 2016 at 4:39 PM, Xiaodi Wu  wrote:

> On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution <
> swift-evolution@swift.org> 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 was thinking of drafting a short proposal if there was enough positive
>> feedback.
>>
>> How does it sound?
>>
>> - Nick
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>

All the best,

Nicholas

Linked in:
http://lnkd.in/328U22


On Wed, May 11, 2016 at 10:11 AM, Tyler Cloutier via swift-evolution <

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 5:56 PM, Chris Lattner  wrote:
> 
> 
>> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution 
>>  wrote:
>> 
>> I agree that repeat { } is ambiguous because you have to look to the end for 
>> a while clause to determine if it's infinite or not.
> 
> Right, this is the downside that I see with “repeat {}”.


Not to beat a dead horse, but isn’t this also true of 

repeat {

} while true

and 

while true {
   ...
   ...
   if condition {
break
   }
}

> 
>> while true { } is preferable in that regard, but a compromise that I saw 
>> mentioned is:
>> 
>> repeat forever { }
> 
> This would require taking “forever” as a keyword if we supported “repeat N 
> {", something we wouldn’t want to do.
> 
> Another option is to make it a statement modifier, which wouldn’t require 
> taking it as a keyword (but also doesn’t read as well):
> 
> forever repeat { }
> 
> 
> Personally, I don’t see this as a big enough improvement over “while true” to 
> be worth introducing complexity for. 
> 

If you are referring to “forever", I also don’t think that adding a new keyword 
is an improvement over “while true”.

> -Chris

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Chris Lattner via swift-evolution

> On May 10, 2016, at 4:13 PM, Cole Campbell via swift-evolution 
>  wrote:
> 
> I agree that repeat { } is ambiguous because you have to look to the end for 
> a while clause to determine if it's infinite or not.

Right, this is the downside that I see with “repeat {}”.

> while true { } is preferable in that regard, but a compromise that I saw 
> mentioned is:
> 
> repeat forever { }

This would require taking “forever” as a keyword if we supported “repeat N {", 
something we wouldn’t want to do.

Another option is to make it a statement modifier, which wouldn’t require 
taking it as a keyword (but also doesn’t read as well):

forever repeat { }


Personally, I don’t see this as a big enough improvement over “while true” to 
be worth introducing complexity for. 

-Chris
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Leonardo Pessoa via swift-evolution
I think a clearer syntax here would be 

   for n in 1...2 { }

as it casts no shadow of doubt about how many times the loop will be executed.

> On 10 May 2016, at 9:27 pm, Tyler Cloutier via swift-evolution 
>  wrote:
> 
> What would repeat 1 { } mean then? Repeat N? Would it run N or N + 1 times? 
> 
> That sounds a massive source of bugs.
> 
> 
>> On May 10, 2016, at 5:25 PM, Xiaodi Wu  wrote:
>> 
>> FWIW, repeat once means do twice.
>> On Tue, May 10, 2016 at 19:16 Tyler Cloutier  wrote:
 On May 10, 2016, at 4:07 PM, Xiaodi Wu  wrote:
 
 
 
 On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier  
 wrote:
> 
>> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
>> 
>>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier  
>>> wrote:
>>> 
 On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
 
> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> I’d actually say that I’m strongly in favor of allowing just a repeat 
> keyword, although I wouldn’t support making 'while true’.
> 
> Firstly it reduces clutter
 
 Can you explain what clutter you see? Unless I misunderstand what 
 you're referring to, reducing the 10 letters in `while true` to the 
 six letters in `repeat` is hardly "reducing clutter."
  
> and makes it very clear that the the code is just supposed to repeat.
 
 I disagree here also. It is not very clear at all that the code is 
 supposed to repeat indefinitely, not to any audience.
 
 First, it would not be clear to users who are experienced in Swift and 
 aware of this proposal. Code is meant to be read, and allowing the 
 omission of a trailing clause to produce two very different behaviors 
 means that it is not clear what `repeat {` means until you encounter 
 the closing brace and check for what follows. Moreover, what follows 
 could be the keyword `while` on the following line, and in that case 
 you cannot know whether the expression that follows `while` is the 
 beginning of a new while loop until you encounter or don't encounter a 
 new opening brace. By contrast, `while true {` cannot be anything 
 other than the beginning of an infinite loop. You already know that 
 fact after reading 12 letters.
 
 Second, it would not be clear to users migrating from another C-family 
 language. `while true { }` is immediately understood by users of any 
 other related language.
 
 Third, it would not be clear based on a knowledge of English. In 
 common use, "repeat" does not mean repeat forever; it means to repeat 
 once (i.e. do something twice). If I ask you to repeat something you 
 just said, I should hope that you do not keep reciting it over and 
 over until I tell you to stop.
  
> Secondly it’s a very simple way of introducing new programmers to 
> loops. It’s IMHO more clear to a new programmer that repeat will just 
> repeat indefinitely vs while true.
 
 I can speak to this a little bit, having introduced a new programmer 
 to loops very recently and having done so in the past as well. I have 
 not encountered anyone who has trouble with the *concept* of 
 looping--i.e. the idea that the same code can be run over and over.
 
 Where things get tricky is the difficulty of mastering the syntax of 
 the while loop and, more problematic, the syntax of the classic for;; 
 loop. Introducing a simple way to make something repeat forever does 
 not solve this learning hurdle, because students will continue to have 
 to contend with these other types of loops in order to be productive 
 in the language. A special syntax for repeating forever is especially 
 unhelpful because it is just functional enough that a discouraged 
 student may choose to avoid learning other types of loops and instead 
 combine the infinite loop with if, continue, and break.
>>> 
>>> I’d also like to point out Chris’ comments on the 
>>> 
>>> repeat X {
>>> 
>>> }
>>> 
>>> discussion.
>>> 
>>> “
>>> This is a very valid use case.
>>> 
>>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>>> implementation of the feature, but was cut due to schedule limitations. 
>>>  There is precedent for this sort of feature in many teaching oriented 
>>> languages (e.g. Logo).
>>> 
>>> I’d say that the pro’s and con’s of this are:
>>> 
>>> + Makes a simple case very simple, particularly important in teaching.
>>> + Even if you aren’t familiar with it, you can tell at first glance 
>>> what the behavior is.
>>

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
I was speaking of what I meant in my written English prose. What `repeat 1`
means is a topic for another day.
On Tue, May 10, 2016 at 19:27 Tyler Cloutier  wrote:

> What would repeat 1 { } mean then? Repeat N? Would it run N or N + 1
> times?
>
> That sounds a massive source of bugs.
>
>
> On May 10, 2016, at 5:25 PM, Xiaodi Wu  wrote:
>
> FWIW, repeat once means do twice.
> On Tue, May 10, 2016 at 19:16 Tyler Cloutier 
> wrote:
>
>> On May 10, 2016, at 4:07 PM, Xiaodi Wu  wrote:
>>
>>
>>
>> On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier 
>> wrote:
>>
>>>
>>> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
>>>
>>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier 
>>> wrote:
>>>

 On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:

 On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution <
 swift-evolution@swift.org> wrote:

> I’d actually say that I’m strongly in favor of allowing just a repeat
> keyword, although I wouldn’t support making 'while true’.
>
> Firstly it reduces clutter
>

 Can you explain what clutter you see? Unless I misunderstand what
 you're referring to, reducing the 10 letters in `while true` to the six
 letters in `repeat` is hardly "reducing clutter."


> and makes it very clear that the the code is just supposed to repeat.
>

 I disagree here also. It is not very clear at all that the code is
 supposed to repeat indefinitely, not to any audience.

 First, it would not be clear to users who are experienced in Swift and
 aware of this proposal. Code is meant to be read, and allowing the omission
 of a trailing clause to produce two very different behaviors means that it
 is not clear what `repeat {` means until you encounter the closing brace
 and check for what follows. Moreover, what follows could be the keyword
 `while` on the following line, and in that case you cannot know whether the
 expression that follows `while` is the beginning of a new while loop until
 you encounter or don't encounter a new opening brace. By contrast, `while
 true {` cannot be anything other than the beginning of an infinite loop.
 You already know that fact after reading 12 letters.

 Second, it would not be clear to users migrating from another C-family
 language. `while true { }` is immediately understood by users of any other
 related language.

 Third, it would not be clear based on a knowledge of English. In common
 use, "repeat" does not mean repeat forever; it means to repeat once (i.e.
 do something twice). If I ask you to repeat something you just said, I
 should hope that you do not keep reciting it over and over until I tell you
 to stop.


> Secondly it’s a very simple way of introducing new programmers to
> loops. It’s IMHO more clear to a new programmer that repeat will just
> repeat indefinitely vs while true.
>

 I can speak to this a little bit, having introduced a new programmer to
 loops very recently and having done so in the past as well. I have not
 encountered anyone who has trouble with the *concept* of looping--i.e. the
 idea that the same code can be run over and over.

 Where things get tricky is the difficulty of mastering the syntax of
 the while loop and, more problematic, the syntax of the classic for;; loop.
 Introducing a simple way to make something repeat forever does not solve
 this learning hurdle, because students will continue to have to contend
 with these other types of loops in order to be productive in the language.
 A special syntax for repeating forever is especially unhelpful because it
 is just functional enough that a discouraged student may choose to avoid
 learning other types of loops and instead combine the infinite loop with
 if, continue, and break.


 I’d also like to point out Chris’ comments on the

 repeat X {

 }

 discussion.

 “

 This is a very valid use case.

 FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
 implementation of the feature, but was cut due to schedule limitations.  
 There is precedent for this sort of feature in many teaching oriented 
 languages (e.g. Logo).

 I’d say that the pro’s and con’s of this are:

 + Makes a simple case very simple, particularly important in teaching.
 + Even if you aren’t familiar with it, you can tell at first glance what 
 the behavior is.
 - It is “just syntactic sugar”, which makes the language more complex.
 - It is a very narrow feature that is useful in few practical situations.

 -Chris

 “

 In this case, I would say it’s not making the language any more complex
 given that repeat-while is a current construct. Admittedly it is a very
 narrow feature, but it’s also a small 

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution
What would repeat 1 { } mean then? Repeat N? Would it run N or N + 1 times? 

That sounds a massive source of bugs.


> On May 10, 2016, at 5:25 PM, Xiaodi Wu  wrote:
> 
> FWIW, repeat once means do twice.
> On Tue, May 10, 2016 at 19:16 Tyler Cloutier  > wrote:
>> On May 10, 2016, at 4:07 PM, Xiaodi Wu > > wrote:
>> 
>> 
>> 
>> On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier > > wrote:
>> 
>>> On May 10, 2016, at 3:59 PM, Xiaodi Wu >> > wrote:
>>> 
>>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier >> > wrote:
>>> 
 On May 10, 2016, at 3:13 PM, Xiaodi Wu >>> > wrote:
 
 On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
 mailto:swift-evolution@swift.org>> wrote:
 I’d actually say that I’m strongly in favor of allowing just a repeat 
 keyword, although I wouldn’t support making 'while true’.
 
 Firstly it reduces clutter
 
 Can you explain what clutter you see? Unless I misunderstand what you're 
 referring to, reducing the 10 letters in `while true` to the six letters 
 in `repeat` is hardly "reducing clutter."
  
 and makes it very clear that the the code is just supposed to repeat.
 
 I disagree here also. It is not very clear at all that the code is 
 supposed to repeat indefinitely, not to any audience.
 
 First, it would not be clear to users who are experienced in Swift and 
 aware of this proposal. Code is meant to be read, and allowing the 
 omission of a trailing clause to produce two very different behaviors 
 means that it is not clear what `repeat {` means until you encounter the 
 closing brace and check for what follows. Moreover, what follows could be 
 the keyword `while` on the following line, and in that case you cannot 
 know whether the expression that follows `while` is the beginning of a new 
 while loop until you encounter or don't encounter a new opening brace. By 
 contrast, `while true {` cannot be anything other than the beginning of an 
 infinite loop. You already know that fact after reading 12 letters.
 
 Second, it would not be clear to users migrating from another C-family 
 language. `while true { }` is immediately understood by users of any other 
 related language.
 
 Third, it would not be clear based on a knowledge of English. In common 
 use, "repeat" does not mean repeat forever; it means to repeat once (i.e. 
 do something twice). If I ask you to repeat something you just said, I 
 should hope that you do not keep reciting it over and over until I tell 
 you to stop.
  
 Secondly it’s a very simple way of introducing new programmers to loops. 
 It’s IMHO more clear to a new programmer that repeat will just repeat 
 indefinitely vs while true.
 
 I can speak to this a little bit, having introduced a new programmer to 
 loops very recently and having done so in the past as well. I have not 
 encountered anyone who has trouble with the *concept* of looping--i.e. the 
 idea that the same code can be run over and over.
 
 Where things get tricky is the difficulty of mastering the syntax of the 
 while loop and, more problematic, the syntax of the classic for;; loop. 
 Introducing a simple way to make something repeat forever does not solve 
 this learning hurdle, because students will continue to have to contend 
 with these other types of loops in order to be productive in the language. 
 A special syntax for repeating forever is especially unhelpful because it 
 is just functional enough that a discouraged student may choose to avoid 
 learning other types of loops and instead combine the infinite loop with 
 if, continue, and break.
>>> 
>>> I’d also like to point out Chris’ comments on the 
>>> 
>>> repeat X {
>>> 
>>> }
>>> 
>>> discussion.
>>> 
>>> “
>>> This is a very valid use case.
>>> 
>>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>>> implementation of the feature, but was cut due to schedule limitations.  
>>> There is precedent for this sort of feature in many teaching oriented 
>>> languages (e.g. Logo).
>>> 
>>> I’d say that the pro’s and con’s of this are:
>>> 
>>> + Makes a simple case very simple, particularly important in teaching.
>>> + Even if you aren’t familiar with it, you can tell at first glance what 
>>> the behavior is.
>>> - It is “just syntactic sugar”, which makes the language more complex.
>>> - It is a very narrow feature that is useful in few practical situations.
>>> 
>>> -Chris
>>> “
>>> 
>>> In this case, I would say it’s not making the language any more complex 
>>> given that repeat-while is a current construct. Admittedly it is a very 
>>> narrow feature, but it’s also a small one.
>>> 
>>

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
FWIW, repeat once means do twice.
On Tue, May 10, 2016 at 19:16 Tyler Cloutier  wrote:

> On May 10, 2016, at 4:07 PM, Xiaodi Wu  wrote:
>
>
>
> On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier 
> wrote:
>
>>
>> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
>>
>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier 
>> wrote:
>>
>>>
>>> On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
>>>
>>> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution <
>>> swift-evolution@swift.org> wrote:
>>>
 I’d actually say that I’m strongly in favor of allowing just a repeat
 keyword, although I wouldn’t support making 'while true’.

 Firstly it reduces clutter

>>>
>>> Can you explain what clutter you see? Unless I misunderstand what you're
>>> referring to, reducing the 10 letters in `while true` to the six letters in
>>> `repeat` is hardly "reducing clutter."
>>>
>>>
 and makes it very clear that the the code is just supposed to repeat.

>>>
>>> I disagree here also. It is not very clear at all that the code is
>>> supposed to repeat indefinitely, not to any audience.
>>>
>>> First, it would not be clear to users who are experienced in Swift and
>>> aware of this proposal. Code is meant to be read, and allowing the omission
>>> of a trailing clause to produce two very different behaviors means that it
>>> is not clear what `repeat {` means until you encounter the closing brace
>>> and check for what follows. Moreover, what follows could be the keyword
>>> `while` on the following line, and in that case you cannot know whether the
>>> expression that follows `while` is the beginning of a new while loop until
>>> you encounter or don't encounter a new opening brace. By contrast, `while
>>> true {` cannot be anything other than the beginning of an infinite loop.
>>> You already know that fact after reading 12 letters.
>>>
>>> Second, it would not be clear to users migrating from another C-family
>>> language. `while true { }` is immediately understood by users of any other
>>> related language.
>>>
>>> Third, it would not be clear based on a knowledge of English. In common
>>> use, "repeat" does not mean repeat forever; it means to repeat once (i.e.
>>> do something twice). If I ask you to repeat something you just said, I
>>> should hope that you do not keep reciting it over and over until I tell you
>>> to stop.
>>>
>>>
 Secondly it’s a very simple way of introducing new programmers to
 loops. It’s IMHO more clear to a new programmer that repeat will just
 repeat indefinitely vs while true.

>>>
>>> I can speak to this a little bit, having introduced a new programmer to
>>> loops very recently and having done so in the past as well. I have not
>>> encountered anyone who has trouble with the *concept* of looping--i.e. the
>>> idea that the same code can be run over and over.
>>>
>>> Where things get tricky is the difficulty of mastering the syntax of the
>>> while loop and, more problematic, the syntax of the classic for;; loop.
>>> Introducing a simple way to make something repeat forever does not solve
>>> this learning hurdle, because students will continue to have to contend
>>> with these other types of loops in order to be productive in the language.
>>> A special syntax for repeating forever is especially unhelpful because it
>>> is just functional enough that a discouraged student may choose to avoid
>>> learning other types of loops and instead combine the infinite loop with
>>> if, continue, and break.
>>>
>>>
>>> I’d also like to point out Chris’ comments on the
>>>
>>> repeat X {
>>>
>>> }
>>>
>>> discussion.
>>>
>>> “
>>>
>>> This is a very valid use case.
>>>
>>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>>> implementation of the feature, but was cut due to schedule limitations.  
>>> There is precedent for this sort of feature in many teaching oriented 
>>> languages (e.g. Logo).
>>>
>>> I’d say that the pro’s and con’s of this are:
>>>
>>> + Makes a simple case very simple, particularly important in teaching.
>>> + Even if you aren’t familiar with it, you can tell at first glance what 
>>> the behavior is.
>>> - It is “just syntactic sugar”, which makes the language more complex.
>>> - It is a very narrow feature that is useful in few practical situations.
>>>
>>> -Chris
>>>
>>> “
>>>
>>> In this case, I would say it’s not making the language any more complex
>>> given that repeat-while is a current construct. Admittedly it is a very
>>> narrow feature, but it’s also a small one.
>>>
>>
>> For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for
>> this case.
>>
>>
>> That’s fair enough. :)
>>
>> But surely you’ll admit that if
>>
>> repeat N {
>>
>> }
>>
>> was valid, then repeat { } follows as the logical repeat indefinitely
>> syntax, no?
>>
>
> No! Not at all! As I wrote above, it could mean repeat once. It currently
> means repeat until the condition that follows, and if that condition is
> optional you only

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 4:07 PM, Xiaodi Wu  wrote:
> 
> 
> 
> On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier  > wrote:
> 
>> On May 10, 2016, at 3:59 PM, Xiaodi Wu > > wrote:
>> 
>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier > > wrote:
>> 
>>> On May 10, 2016, at 3:13 PM, Xiaodi Wu >> > wrote:
>>> 
>>> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> I’d actually say that I’m strongly in favor of allowing just a repeat 
>>> keyword, although I wouldn’t support making 'while true’.
>>> 
>>> Firstly it reduces clutter
>>> 
>>> Can you explain what clutter you see? Unless I misunderstand what you're 
>>> referring to, reducing the 10 letters in `while true` to the six letters in 
>>> `repeat` is hardly "reducing clutter."
>>>  
>>> and makes it very clear that the the code is just supposed to repeat.
>>> 
>>> I disagree here also. It is not very clear at all that the code is supposed 
>>> to repeat indefinitely, not to any audience.
>>> 
>>> First, it would not be clear to users who are experienced in Swift and 
>>> aware of this proposal. Code is meant to be read, and allowing the omission 
>>> of a trailing clause to produce two very different behaviors means that it 
>>> is not clear what `repeat {` means until you encounter the closing brace 
>>> and check for what follows. Moreover, what follows could be the keyword 
>>> `while` on the following line, and in that case you cannot know whether the 
>>> expression that follows `while` is the beginning of a new while loop until 
>>> you encounter or don't encounter a new opening brace. By contrast, `while 
>>> true {` cannot be anything other than the beginning of an infinite loop. 
>>> You already know that fact after reading 12 letters.
>>> 
>>> Second, it would not be clear to users migrating from another C-family 
>>> language. `while true { }` is immediately understood by users of any other 
>>> related language.
>>> 
>>> Third, it would not be clear based on a knowledge of English. In common 
>>> use, "repeat" does not mean repeat forever; it means to repeat once (i.e. 
>>> do something twice). If I ask you to repeat something you just said, I 
>>> should hope that you do not keep reciting it over and over until I tell you 
>>> to stop.
>>>  
>>> Secondly it’s a very simple way of introducing new programmers to loops. 
>>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>>> indefinitely vs while true.
>>> 
>>> I can speak to this a little bit, having introduced a new programmer to 
>>> loops very recently and having done so in the past as well. I have not 
>>> encountered anyone who has trouble with the *concept* of looping--i.e. the 
>>> idea that the same code can be run over and over.
>>> 
>>> Where things get tricky is the difficulty of mastering the syntax of the 
>>> while loop and, more problematic, the syntax of the classic for;; loop. 
>>> Introducing a simple way to make something repeat forever does not solve 
>>> this learning hurdle, because students will continue to have to contend 
>>> with these other types of loops in order to be productive in the language. 
>>> A special syntax for repeating forever is especially unhelpful because it 
>>> is just functional enough that a discouraged student may choose to avoid 
>>> learning other types of loops and instead combine the infinite loop with 
>>> if, continue, and break.
>> 
>> I’d also like to point out Chris’ comments on the 
>> 
>> repeat X {
>> 
>> }
>> 
>> discussion.
>> 
>> “
>> This is a very valid use case.
>> 
>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>> implementation of the feature, but was cut due to schedule limitations.  
>> There is precedent for this sort of feature in many teaching oriented 
>> languages (e.g. Logo).
>> 
>> I’d say that the pro’s and con’s of this are:
>> 
>> + Makes a simple case very simple, particularly important in teaching.
>> + Even if you aren’t familiar with it, you can tell at first glance what the 
>> behavior is.
>> - It is “just syntactic sugar”, which makes the language more complex.
>> - It is a very narrow feature that is useful in few practical situations.
>> 
>> -Chris
>> “
>> 
>> In this case, I would say it’s not making the language any more complex 
>> given that repeat-while is a current construct. Admittedly it is a very 
>> narrow feature, but it’s also a small one.
>> 
>> For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for this 
>> case.
>> 
> 
> That’s fair enough. :)
> 
> But surely you’ll admit that if 
> 
> repeat N {
> 
> }
> 
> was valid, then repeat { } follows as the logical repeat indefinitely syntax, 
> no?
> 
> No! Not at all! As I wrote above, it could mean repeat once. It currently 
> means repeat until the condition that follows, and if that condition is 
> 

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
Right. I'd like to echo Erica, though, and add my thanks to Nicholas for
bringing it up. It certainly prompted a discussion, and it was a refreshing
idea indeed.
On Tue, May 10, 2016 at 18:19 Cole Campbell 
wrote:

>
> That’s fair enough. :)
>>
>> But surely you’ll admit that if
>>
>> repeat N {
>>
>> }
>>
>> was valid, then repeat { } follows as the logical repeat indefinitely
>> syntax, no?
>>
>
> No! Not at all! As I wrote above, it could mean repeat once. It currently
> means repeat until the condition that follows, and if that condition is
> optional you only find out after you read everything in the loop. So, IMO,
> it does not follow at all!
>
>
> I agree, it doesn't follow that if repeat N { } exists then somehow repeat
> without an argument means 'forever'. In English, 'repeat' without anything
> to indicate how many time means 'repeat once'.
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Cole Campbell via swift-evolution

>> That’s fair enough. :)
>> 
>> But surely you’ll admit that if 
>> 
>> repeat N {
>> 
>> }
>> 
>> was valid, then repeat { } follows as the logical repeat indefinitely 
>> syntax, no?
> 
> No! Not at all! As I wrote above, it could mean repeat once. It currently 
> means repeat until the condition that follows, and if that condition is 
> optional you only find out after you read everything in the loop. So, IMO, it 
> does not follow at all!

I agree, it doesn't follow that if repeat N { } exists then somehow repeat 
without an argument means 'forever'. In English, 'repeat' without anything to 
indicate how many time means 'repeat once'.___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier 
wrote:

Let me be explicit about how the two ideas compare.

> I’d also like to point out Chris’ comments on the
>>
>> repeat X {
>>
>> }
>>
>> discussion.
>>
>> “
>>
>> This is a very valid use case.
>>
>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>> implementation of the feature, but was cut due to schedule limitations.  
>> There is precedent for this sort of feature in many teaching oriented 
>> languages (e.g. Logo).
>>
>> I’d say that the pro’s and con’s of this are:
>>
>> + Makes a simple case very simple, particularly important in teaching.
>>
>>
Repeating N times is a simple case, and `repeat N { }` makes it simple.
Repeating an indefinite number of times is not really a simple case--at
least, it's not the same case--and it's not even profitably usable until a
beginner has mastered another concept, namely `break`.


> + Even if you aren’t familiar with it, you can tell at first glance what the 
> behavior is.
>>
>>
As I've mentioned above and Cole has just reinforced, with this proposal,
you can't tell at first glance what the behavior of `repeat {` is until you
read the end brace--even if you *are* familiar with it. By contrast,
`repeat N { }` is immediately understood, whether or not you're familiar
with it.


> - It is “just syntactic sugar”, which makes the language more complex.
>>
>>
Whether you naively compare letters saved or concepts invoked, `repeat N {
}` is very sweet sugar in comparison to `for _ in 0.. - It is a very narrow feature that is useful in few practical situations.
>>
>>
Here, `repeat N { }` can be used for any value N, but `repeat { }` is
useful only for saving four letters from `while true { }`.


>
>> -Chris
>>
>> “
>>
>> In this case, I would say it’s not making the language any more complex
>> given that repeat-while is a current construct. Admittedly it is a very
>> narrow feature, but it’s also a small one.
>>
>
> For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for this
> case.
>
>
> That’s fair enough. :)
>
> But surely you’ll admit that if
>
> repeat N {
>
> }
>
> was valid, then repeat { } follows as the logical repeat indefinitely
> syntax, no?
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Cole Campbell via swift-evolution
I agree that repeat { } is ambiguous because you have to look to the end for a 
while clause to determine if it's infinite or not. while true { } is preferable 
in that regard, but a compromise that I saw mentioned is:

repeat forever { }

That is immediately clear that it is infinite like while true { } but reads 
better in English. And it's a nice extension of repeat N { }, which is 
something I wouldn't mind seeing being added to the language.

So +1 for repeat N { }, +1 for repeat forever { }, -1 for repeat { }.

> On May 10, 2016, at 6:02 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> 
> 
>> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
>> 
>>> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier  
>>> wrote:
>>> 
 On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
 
> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> I’d actually say that I’m strongly in favor of allowing just a repeat 
> keyword, although I wouldn’t support making 'while true’.
> 
> Firstly it reduces clutter
 
 Can you explain what clutter you see? Unless I misunderstand what you're 
 referring to, reducing the 10 letters in `while true` to the six letters 
 in `repeat` is hardly "reducing clutter."
  
> and makes it very clear that the the code is just supposed to repeat.
 
 I disagree here also. It is not very clear at all that the code is 
 supposed to repeat indefinitely, not to any audience.
 
 First, it would not be clear to users who are experienced in Swift and 
 aware of this proposal. Code is meant to be read, and allowing the 
 omission of a trailing clause to produce two very different behaviors 
 means that it is not clear what `repeat {` means until you encounter the 
 closing brace and check for what follows. Moreover, what follows could be 
 the keyword `while` on the following line, and in that case you cannot 
 know whether the expression that follows `while` is the beginning of a new 
 while loop until you encounter or don't encounter a new opening brace. By 
 contrast, `while true {` cannot be anything other than the beginning of an 
 infinite loop. You already know that fact after reading 12 letters.
 
 Second, it would not be clear to users migrating from another C-family 
 language. `while true { }` is immediately understood by users of any other 
 related language.
 
 Third, it would not be clear based on a knowledge of English. In common 
 use, "repeat" does not mean repeat forever; it means to repeat once (i.e. 
 do something twice). If I ask you to repeat something you just said, I 
 should hope that you do not keep reciting it over and over until I tell 
 you to stop.
  
> Secondly it’s a very simple way of introducing new programmers to loops. 
> It’s IMHO more clear to a new programmer that repeat will just repeat 
> indefinitely vs while true.
 
 I can speak to this a little bit, having introduced a new programmer to 
 loops very recently and having done so in the past as well. I have not 
 encountered anyone who has trouble with the *concept* of looping--i.e. the 
 idea that the same code can be run over and over.
 
 Where things get tricky is the difficulty of mastering the syntax of the 
 while loop and, more problematic, the syntax of the classic for;; loop. 
 Introducing a simple way to make something repeat forever does not solve 
 this learning hurdle, because students will continue to have to contend 
 with these other types of loops in order to be productive in the language. 
 A special syntax for repeating forever is especially unhelpful because it 
 is just functional enough that a discouraged student may choose to avoid 
 learning other types of loops and instead combine the infinite loop with 
 if, continue, and break.
>>> 
>>> I’d also like to point out Chris’ comments on the 
>>> 
>>> repeat X {
>>> 
>>> }
>>> 
>>> discussion.
>>> 
>>> “
>>> This is a very valid use case.
>>> 
>>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>>> implementation of the feature, but was cut due to schedule limitations.  
>>> There is precedent for this sort of feature in many teaching oriented 
>>> languages (e.g. Logo).
>>> 
>>> I’d say that the pro’s and con’s of this are:
>>> 
>>> + Makes a simple case very simple, particularly important in teaching.
>>> + Even if you aren’t familiar with it, you can tell at first glance what 
>>> the behavior is.
>>> - It is “just syntactic sugar”, which makes the language more complex.
>>> - It is a very narrow feature that is useful in few practical situations.
>>> 
>>> -Chris
>>> “
>>> 
>>> In this case, I would say it’s not making the language any more complex 
>>> given that repeat-while is a current construct. Admittedly it is a very 
>>> narrow feature, but it’s also a small one.
>> 

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 6:02 PM, Tyler Cloutier 
wrote:

>
> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
>
> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier 
> wrote:
>
>>
>> On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
>>
>> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>>> I’d actually say that I’m strongly in favor of allowing just a repeat
>>> keyword, although I wouldn’t support making 'while true’.
>>>
>>> Firstly it reduces clutter
>>>
>>
>> Can you explain what clutter you see? Unless I misunderstand what you're
>> referring to, reducing the 10 letters in `while true` to the six letters in
>> `repeat` is hardly "reducing clutter."
>>
>>
>>> and makes it very clear that the the code is just supposed to repeat.
>>>
>>
>> I disagree here also. It is not very clear at all that the code is
>> supposed to repeat indefinitely, not to any audience.
>>
>> First, it would not be clear to users who are experienced in Swift and
>> aware of this proposal. Code is meant to be read, and allowing the omission
>> of a trailing clause to produce two very different behaviors means that it
>> is not clear what `repeat {` means until you encounter the closing brace
>> and check for what follows. Moreover, what follows could be the keyword
>> `while` on the following line, and in that case you cannot know whether the
>> expression that follows `while` is the beginning of a new while loop until
>> you encounter or don't encounter a new opening brace. By contrast, `while
>> true {` cannot be anything other than the beginning of an infinite loop.
>> You already know that fact after reading 12 letters.
>>
>> Second, it would not be clear to users migrating from another C-family
>> language. `while true { }` is immediately understood by users of any other
>> related language.
>>
>> Third, it would not be clear based on a knowledge of English. In common
>> use, "repeat" does not mean repeat forever; it means to repeat once (i.e.
>> do something twice). If I ask you to repeat something you just said, I
>> should hope that you do not keep reciting it over and over until I tell you
>> to stop.
>>
>>
>>> Secondly it’s a very simple way of introducing new programmers to loops.
>>> It’s IMHO more clear to a new programmer that repeat will just repeat
>>> indefinitely vs while true.
>>>
>>
>> I can speak to this a little bit, having introduced a new programmer to
>> loops very recently and having done so in the past as well. I have not
>> encountered anyone who has trouble with the *concept* of looping--i.e. the
>> idea that the same code can be run over and over.
>>
>> Where things get tricky is the difficulty of mastering the syntax of the
>> while loop and, more problematic, the syntax of the classic for;; loop.
>> Introducing a simple way to make something repeat forever does not solve
>> this learning hurdle, because students will continue to have to contend
>> with these other types of loops in order to be productive in the language.
>> A special syntax for repeating forever is especially unhelpful because it
>> is just functional enough that a discouraged student may choose to avoid
>> learning other types of loops and instead combine the infinite loop with
>> if, continue, and break.
>>
>>
>> I’d also like to point out Chris’ comments on the
>>
>> repeat X {
>>
>> }
>>
>> discussion.
>>
>> “
>>
>> This is a very valid use case.
>>
>> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
>> implementation of the feature, but was cut due to schedule limitations.  
>> There is precedent for this sort of feature in many teaching oriented 
>> languages (e.g. Logo).
>>
>> I’d say that the pro’s and con’s of this are:
>>
>> + Makes a simple case very simple, particularly important in teaching.
>> + Even if you aren’t familiar with it, you can tell at first glance what the 
>> behavior is.
>> - It is “just syntactic sugar”, which makes the language more complex.
>> - It is a very narrow feature that is useful in few practical situations.
>>
>> -Chris
>>
>> “
>>
>> In this case, I would say it’s not making the language any more complex
>> given that repeat-while is a current construct. Admittedly it is a very
>> narrow feature, but it’s also a small one.
>>
>
> For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for this
> case.
>
>
> That’s fair enough. :)
>
> But surely you’ll admit that if
>
> repeat N {
>
> }
>
> was valid, then repeat { } follows as the logical repeat indefinitely
> syntax, no?
>

No! Not at all! As I wrote above, it could mean repeat once. It currently
means repeat until the condition that follows, and if that condition is
optional you only find out after you read everything in the loop. So, IMO,
it does not follow at all!


>
>
>
>>
>>
>>
>>> Lastly, this isn’t the first time this has been brought up on this list
>>> and there was previously discussion about the fact that when people see the
>>> repeat keyword

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 3:59 PM, Xiaodi Wu  wrote:
> 
> On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier  > wrote:
> 
>> On May 10, 2016, at 3:13 PM, Xiaodi Wu > > wrote:
>> 
>> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> I’d actually say that I’m strongly in favor of allowing just a repeat 
>> keyword, although I wouldn’t support making 'while true’.
>> 
>> Firstly it reduces clutter
>> 
>> Can you explain what clutter you see? Unless I misunderstand what you're 
>> referring to, reducing the 10 letters in `while true` to the six letters in 
>> `repeat` is hardly "reducing clutter."
>>  
>> and makes it very clear that the the code is just supposed to repeat.
>> 
>> I disagree here also. It is not very clear at all that the code is supposed 
>> to repeat indefinitely, not to any audience.
>> 
>> First, it would not be clear to users who are experienced in Swift and aware 
>> of this proposal. Code is meant to be read, and allowing the omission of a 
>> trailing clause to produce two very different behaviors means that it is not 
>> clear what `repeat {` means until you encounter the closing brace and check 
>> for what follows. Moreover, what follows could be the keyword `while` on the 
>> following line, and in that case you cannot know whether the expression that 
>> follows `while` is the beginning of a new while loop until you encounter or 
>> don't encounter a new opening brace. By contrast, `while true {` cannot be 
>> anything other than the beginning of an infinite loop. You already know that 
>> fact after reading 12 letters.
>> 
>> Second, it would not be clear to users migrating from another C-family 
>> language. `while true { }` is immediately understood by users of any other 
>> related language.
>> 
>> Third, it would not be clear based on a knowledge of English. In common use, 
>> "repeat" does not mean repeat forever; it means to repeat once (i.e. do 
>> something twice). If I ask you to repeat something you just said, I should 
>> hope that you do not keep reciting it over and over until I tell you to stop.
>>  
>> Secondly it’s a very simple way of introducing new programmers to loops. 
>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>> indefinitely vs while true.
>> 
>> I can speak to this a little bit, having introduced a new programmer to 
>> loops very recently and having done so in the past as well. I have not 
>> encountered anyone who has trouble with the *concept* of looping--i.e. the 
>> idea that the same code can be run over and over.
>> 
>> Where things get tricky is the difficulty of mastering the syntax of the 
>> while loop and, more problematic, the syntax of the classic for;; loop. 
>> Introducing a simple way to make something repeat forever does not solve 
>> this learning hurdle, because students will continue to have to contend with 
>> these other types of loops in order to be productive in the language. A 
>> special syntax for repeating forever is especially unhelpful because it is 
>> just functional enough that a discouraged student may choose to avoid 
>> learning other types of loops and instead combine the infinite loop with if, 
>> continue, and break.
> 
> I’d also like to point out Chris’ comments on the 
> 
> repeat X {
> 
> }
> 
> discussion.
> 
> “
> This is a very valid use case.
> 
> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
> implementation of the feature, but was cut due to schedule limitations.  
> There is precedent for this sort of feature in many teaching oriented 
> languages (e.g. Logo).
> 
> I’d say that the pro’s and con’s of this are:
> 
> + Makes a simple case very simple, particularly important in teaching.
> + Even if you aren’t familiar with it, you can tell at first glance what the 
> behavior is.
> - It is “just syntactic sugar”, which makes the language more complex.
> - It is a very narrow feature that is useful in few practical situations.
> 
> -Chris
> “
> 
> In this case, I would say it’s not making the language any more complex given 
> that repeat-while is a current construct. Admittedly it is a very narrow 
> feature, but it’s also a small one.
> 
> For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for this 
> case.
> 

That’s fair enough. :)

But surely you’ll admit that if 

repeat N {

}

was valid, then repeat { } follows as the logical repeat indefinitely syntax, 
no?


>  
> 
>>  
>> Lastly, this isn’t the first time this has been brought up on this list and 
>> there was previously discussion about the fact that when people see the 
>> repeat keyword that it should naturally repeat indefinitely unless a where 
>> clause is specified.
>> 
>> I do believe that this is the first time this suggestion has been introduced 
>> to the list. I do not recall any previous discussion focused on infinite 
>> loops; they have been abo

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 5:56 PM, Tyler Cloutier 
wrote:

>
> On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
>
> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution <
> swift-evolution@swift.org> wrote:
>
>> I’d actually say that I’m strongly in favor of allowing just a repeat
>> keyword, although I wouldn’t support making 'while true’.
>>
>> Firstly it reduces clutter
>>
>
> Can you explain what clutter you see? Unless I misunderstand what you're
> referring to, reducing the 10 letters in `while true` to the six letters in
> `repeat` is hardly "reducing clutter."
>
>
>> and makes it very clear that the the code is just supposed to repeat.
>>
>
> I disagree here also. It is not very clear at all that the code is
> supposed to repeat indefinitely, not to any audience.
>
> First, it would not be clear to users who are experienced in Swift and
> aware of this proposal. Code is meant to be read, and allowing the omission
> of a trailing clause to produce two very different behaviors means that it
> is not clear what `repeat {` means until you encounter the closing brace
> and check for what follows. Moreover, what follows could be the keyword
> `while` on the following line, and in that case you cannot know whether the
> expression that follows `while` is the beginning of a new while loop until
> you encounter or don't encounter a new opening brace. By contrast, `while
> true {` cannot be anything other than the beginning of an infinite loop.
> You already know that fact after reading 12 letters.
>
> Second, it would not be clear to users migrating from another C-family
> language. `while true { }` is immediately understood by users of any other
> related language.
>
> Third, it would not be clear based on a knowledge of English. In common
> use, "repeat" does not mean repeat forever; it means to repeat once (i.e.
> do something twice). If I ask you to repeat something you just said, I
> should hope that you do not keep reciting it over and over until I tell you
> to stop.
>
>
>> Secondly it’s a very simple way of introducing new programmers to loops.
>> It’s IMHO more clear to a new programmer that repeat will just repeat
>> indefinitely vs while true.
>>
>
> I can speak to this a little bit, having introduced a new programmer to
> loops very recently and having done so in the past as well. I have not
> encountered anyone who has trouble with the *concept* of looping--i.e. the
> idea that the same code can be run over and over.
>
> Where things get tricky is the difficulty of mastering the syntax of the
> while loop and, more problematic, the syntax of the classic for;; loop.
> Introducing a simple way to make something repeat forever does not solve
> this learning hurdle, because students will continue to have to contend
> with these other types of loops in order to be productive in the language.
> A special syntax for repeating forever is especially unhelpful because it
> is just functional enough that a discouraged student may choose to avoid
> learning other types of loops and instead combine the infinite loop with
> if, continue, and break.
>
>
> I’d also like to point out Chris’ comments on the
>
> repeat X {
>
> }
>
> discussion.
>
> “
>
> This is a very valid use case.
>
> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
> implementation of the feature, but was cut due to schedule limitations.  
> There is precedent for this sort of feature in many teaching oriented 
> languages (e.g. Logo).
>
> I’d say that the pro’s and con’s of this are:
>
> + Makes a simple case very simple, particularly important in teaching.
> + Even if you aren’t familiar with it, you can tell at first glance what the 
> behavior is.
> - It is “just syntactic sugar”, which makes the language more complex.
> - It is a very narrow feature that is useful in few practical situations.
>
> -Chris
>
> “
>
> In this case, I would say it’s not making the language any more complex
> given that repeat-while is a current construct. Admittedly it is a very
> narrow feature, but it’s also a small one.
>

For the reasons I outlined above, I'd be +1 for `repeat N` and -1 for this
case.



>
>
>
>> Lastly, this isn’t the first time this has been brought up on this list
>> and there was previously discussion about the fact that when people see the
>> repeat keyword that it should naturally repeat indefinitely unless a where
>> clause is specified.
>>
>
> I do believe that this is the first time this suggestion has been
> introduced to the list. I do not recall any previous discussion focused on
> infinite loops; they have been about repeating a finite number of times,
> using proposed syntax such as `repeat 3 times { }` or variations on that
> theme.
>
>
>> I also think the concern that an accidental infinite loop is any greater
>> than it is currently.
>>
>
> Code gets refactored and edited. We're discussing on another thread
> changing the rules about dangling commas in parameter lists for that very
> rea

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 3:56 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> 
>> 
>> On May 10, 2016, at 3:13 PM, Xiaodi Wu > > wrote:
>> 
>> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> I’d actually say that I’m strongly in favor of allowing just a repeat 
>> keyword, although I wouldn’t support making 'while true’.
>> 
>> Firstly it reduces clutter
>> 
>> Can you explain what clutter you see? Unless I misunderstand what you're 
>> referring to, reducing the 10 letters in `while true` to the six letters in 
>> `repeat` is hardly "reducing clutter."
>>  
>> and makes it very clear that the the code is just supposed to repeat.
>> 
>> I disagree here also. It is not very clear at all that the code is supposed 
>> to repeat indefinitely, not to any audience.
>> 
>> First, it would not be clear to users who are experienced in Swift and aware 
>> of this proposal. Code is meant to be read, and allowing the omission of a 
>> trailing clause to produce two very different behaviors means that it is not 
>> clear what `repeat {` means until you encounter the closing brace and check 
>> for what follows. Moreover, what follows could be the keyword `while` on the 
>> following line, and in that case you cannot know whether the expression that 
>> follows `while` is the beginning of a new while loop until you encounter or 
>> don't encounter a new opening brace. By contrast, `while true {` cannot be 
>> anything other than the beginning of an infinite loop. You already know that 
>> fact after reading 12 letters.
>> 
>> Second, it would not be clear to users migrating from another C-family 
>> language. `while true { }` is immediately understood by users of any other 
>> related language.
>> 
>> Third, it would not be clear based on a knowledge of English. In common use, 
>> "repeat" does not mean repeat forever; it means to repeat once (i.e. do 
>> something twice). If I ask you to repeat something you just said, I should 
>> hope that you do not keep reciting it over and over until I tell you to stop.
>>  
>> Secondly it’s a very simple way of introducing new programmers to loops. 
>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>> indefinitely vs while true.
>> 
>> I can speak to this a little bit, having introduced a new programmer to 
>> loops very recently and having done so in the past as well. I have not 
>> encountered anyone who has trouble with the *concept* of looping--i.e. the 
>> idea that the same code can be run over and over.
>> 
>> Where things get tricky is the difficulty of mastering the syntax of the 
>> while loop and, more problematic, the syntax of the classic for;; loop. 
>> Introducing a simple way to make something repeat forever does not solve 
>> this learning hurdle, because students will continue to have to contend with 
>> these other types of loops in order to be productive in the language. A 
>> special syntax for repeating forever is especially unhelpful because it is 
>> just functional enough that a discouraged student may choose to avoid 
>> learning other types of loops and instead combine the infinite loop with if, 
>> continue, and break.
> 
> I’d also like to point out Chris’ comments on the 
> 
> repeat X {
> 
> }
> 
> discussion.
> 
> “
> This is a very valid use case.
> 
> FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
> implementation of the feature, but was cut due to schedule limitations.  
> There is precedent for this sort of feature in many teaching oriented 
> languages (e.g. Logo).
> 
> I’d say that the pro’s and con’s of this are:
> 
> + Makes a simple case very simple, particularly important in teaching.
> + Even if you aren’t familiar with it, you can tell at first glance what the 
> behavior is.
> - It is “just syntactic sugar”, which makes the language more complex.
> - It is a very narrow feature that is useful in few practical situations.
> 
> -Chris
> “
> 

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001234.html

> In this case, I would say it’s not making the language any more complex given 
> that repeat-while is a current construct. Admittedly it is a very narrow 
> feature, but it’s also a small one.
> 
>>  
>> Lastly, this isn’t the first time this has been brought up on this list and 
>> there was previously discussion about the fact that when people see the 
>> repeat keyword that it should naturally repeat indefinitely unless a where 
>> clause is specified.
>> 
>> I do believe that this is the first time this suggestion has been introduced 
>> to the list. I do not recall any previous discussion focused on infinite 
>> loops; they have been about repeating a finite number of times, using 
>> proposed syntax such as `repeat 3 times { }` or variations on that theme.
>>  
>> I also think the concern that an accidental infinite loop is any greater 
>> than it is currently.
>

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
> 
> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> I’d actually say that I’m strongly in favor of allowing just a repeat 
> keyword, although I wouldn’t support making 'while true’.
> 
> Firstly it reduces clutter
> 
> Can you explain what clutter you see? Unless I misunderstand what you're 
> referring to, reducing the 10 letters in `while true` to the six letters in 
> `repeat` is hardly "reducing clutter."
>  
> and makes it very clear that the the code is just supposed to repeat.
> 
> I disagree here also. It is not very clear at all that the code is supposed 
> to repeat indefinitely, not to any audience.
> 
> First, it would not be clear to users who are experienced in Swift and aware 
> of this proposal. Code is meant to be read, and allowing the omission of a 
> trailing clause to produce two very different behaviors means that it is not 
> clear what `repeat {` means until you encounter the closing brace and check 
> for what follows. Moreover, what follows could be the keyword `while` on the 
> following line, and in that case you cannot know whether the expression that 
> follows `while` is the beginning of a new while loop until you encounter or 
> don't encounter a new opening brace. By contrast, `while true {` cannot be 
> anything other than the beginning of an infinite loop. You already know that 
> fact after reading 12 letters.
> 
> Second, it would not be clear to users migrating from another C-family 
> language. `while true { }` is immediately understood by users of any other 
> related language.
> 
> Third, it would not be clear based on a knowledge of English. In common use, 
> "repeat" does not mean repeat forever; it means to repeat once (i.e. do 
> something twice). If I ask you to repeat something you just said, I should 
> hope that you do not keep reciting it over and over until I tell you to stop.
>  
> Secondly it’s a very simple way of introducing new programmers to loops. It’s 
> IMHO more clear to a new programmer that repeat will just repeat indefinitely 
> vs while true.
> 
> I can speak to this a little bit, having introduced a new programmer to loops 
> very recently and having done so in the past as well. I have not encountered 
> anyone who has trouble with the *concept* of looping--i.e. the idea that the 
> same code can be run over and over.
> 
> Where things get tricky is the difficulty of mastering the syntax of the 
> while loop and, more problematic, the syntax of the classic for;; loop. 
> Introducing a simple way to make something repeat forever does not solve this 
> learning hurdle, because students will continue to have to contend with these 
> other types of loops in order to be productive in the language. A special 
> syntax for repeating forever is especially unhelpful because it is just 
> functional enough that a discouraged student may choose to avoid learning 
> other types of loops and instead combine the infinite loop with if, continue, 
> and break.

I’d also like to point out Chris’ comments on the 

repeat X {

}

discussion.

“
This is a very valid use case.

FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 
implementation of the feature, but was cut due to schedule limitations.  There 
is precedent for this sort of feature in many teaching oriented languages (e.g. 
Logo).

I’d say that the pro’s and con’s of this are:

+ Makes a simple case very simple, particularly important in teaching.
+ Even if you aren’t familiar with it, you can tell at first glance what the 
behavior is.
- It is “just syntactic sugar”, which makes the language more complex.
- It is a very narrow feature that is useful in few practical situations.

-Chris
“

In this case, I would say it’s not making the language any more complex given 
that repeat-while is a current construct. Admittedly it is a very narrow 
feature, but it’s also a small one.

>  
> Lastly, this isn’t the first time this has been brought up on this list and 
> there was previously discussion about the fact that when people see the 
> repeat keyword that it should naturally repeat indefinitely unless a where 
> clause is specified.
> 
> I do believe that this is the first time this suggestion has been introduced 
> to the list. I do not recall any previous discussion focused on infinite 
> loops; they have been about repeating a finite number of times, using 
> proposed syntax such as `repeat 3 times { }` or variations on that theme.
>  
> I also think the concern that an accidental infinite loop is any greater than 
> it is currently.
> 
> Code gets refactored and edited. We're discussing on another thread changing 
> the rules about dangling commas in parameter lists for that very reason. If 
> you try to move a block of code with a repeat...while loop but accidentally 
> leave behind the last line, this syntax will cause you grief.
>  
> Tyler
> 
> 
> 
>> On Ma

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 3:13 PM, Xiaodi Wu  wrote:
> 
> On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> I’d actually say that I’m strongly in favor of allowing just a repeat 
> keyword, although I wouldn’t support making 'while true’.
> 
> Firstly it reduces clutter
> 
> Can you explain what clutter you see? Unless I misunderstand what you're 
> referring to, reducing the 10 letters in `while true` to the six letters in 
> `repeat` is hardly "reducing clutter.”

I’m just referring to 'repeat {} while true’ -> 'repeat {}' 

>  
> and makes it very clear that the the code is just supposed to repeat.
> 
> I disagree here also. It is not very clear at all that the code is supposed 
> to repeat indefinitely, not to any audience.
> 
> First, it would not be clear to users who are experienced in Swift and aware 
> of this proposal. Code is meant to be read, and allowing the omission of a 
> trailing clause to produce two very different behaviors means that it is not 
> clear what `repeat {` means until you encounter the closing brace and check 
> for what follows.

This is just as true of all types of loops. If I have 

repeat {
...
} while ...

I still have to scroll down to check the condition.

If I have 

while true {
...
}

I still have to scan the entire body for different ways of exiting the loop. 

> Moreover, what follows could be the keyword `while` on the following line, 
> and in that case you cannot know whether the expression that follows `while` 
> is the beginning of a new while loop until you encounter or don't encounter a 
> new opening brace.

This is true, but it’s not ambiguous and any reasonable style would make it 
clear what the intension is. However, this does sound difficult for the 
compiler to parse, I will admit. This whole thing might be a moot point if 
can’t be integrated into the grammar. I don’t think I’m qualified to comment on 
the implications there.

> By contrast, `while true {` cannot be anything other than the beginning of an 
> infinite loop. You already know that fact after reading 12 letters.
> 

As I’ve said above, this is not true. I can break out of the loop at any time.

> Second, it would not be clear to users migrating from another C-family 
> language. `while true { }` is immediately understood by users of any other 
> related language.

repeat as a keyword is already unfamiliar to users from other C-family 
languages. If they can grok the repeat-while loop, they can definitely 
understand repeat immediately.

> 
> Third, it would not be clear based on a knowledge of English. In common use, 
> "repeat" does not mean repeat forever; it means to repeat once (i.e. do 
> something twice). If I ask you to repeat something you just said, I should 
> hope that you do not keep reciting it over and over until I tell you to stop.
>  
> Secondly it’s a very simple way of introducing new programmers to loops. It’s 
> IMHO more clear to a new programmer that repeat will just repeat indefinitely 
> vs while true.
> 
> I can speak to this a little bit, having introduced a new programmer to loops 
> very recently and having done so in the past as well. I have not encountered 
> anyone who has trouble with the *concept* of looping--i.e. the idea that the 
> same code can be run over and over.
> 
> Where things get tricky is the difficulty of mastering the syntax of the 
> while loop and, more problematic, the syntax of the classic for;; loop. 
> Introducing a simple way to make something repeat forever does not solve this 
> learning hurdle, because students will continue to have to contend with these 
> other types of loops in order to be productive in the language.

You’re saying that we should not have a simple syntax because they will 
eventually have to understand more complex syntax? Or am I misunderstanding?

> A special syntax for repeating forever is especially unhelpful because it is 
> just functional enough that a discouraged student may choose to avoid 
> learning other types of loops and instead combine the infinite loop with if, 
> continue, and break.
>  
> Lastly, this isn’t the first time this has been brought up on this list and 
> there was previously discussion about the fact that when people see the 
> repeat keyword that it should naturally repeat indefinitely unless a where 
> clause is specified.
> 
> I do believe that this is the first time this suggestion has been introduced 
> to the list. I do not recall any previous discussion focused on infinite 
> loops; they have been about repeating a finite number of times, using 
> proposed syntax such as `repeat 3 times { }` or variations on that theme.
>  

Yes, that's the discussion I was referring to, and you can see that proponents 
had very similar arguments to the one I’m presenting now.

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001144.html

> I also think the concern that an accidental infinite loop i

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 4:57 PM, Tyler Cloutier 
wrote:

>
> On May 10, 2016, at 2:50 PM, Xiaodi Wu  wrote:
>
>
>
> On Tue, May 10, 2016 at 4:46 PM, Tyler Cloutier 
> wrote:
>
>>
>> On May 10, 2016, at 2:34 PM, Xiaodi Wu  wrote:
>>
>> I think, on the contrary, it's missing the point utterly. It's up to
>> those proposing a new feature to justify its addition in light of what's
>> already here, and it's up to those proposing the removal of a feature to
>> justify why it should be removed.
>>
>> Certainly no one is proposing the removal of the while loop. Currently,
>> the One Obvious Way of making an infinite loop is `while true`, and it is
>> up to the proponents to advance a reason why a replacement would be
>> superior. I cannot think of a greater non-sequitur than supplying a
>> demonstration of why while loops are useful.
>>
>>
>> That’s what I am saying. No one is supplying a demonstration of why while
>> loops are useful and that suggestion is a straw man.
>>
>
> That was not meant to be a straw man, not on my part. It is my
> understanding of Harlan's example. It shows that, without while loops, it
> is unwieldy to express the same thing using goto statements. That is fine,
> but it is not at all on point for this discussion.
>
>
>> My point below that simple and clear syntax is an improvement on syntax
>> with more noise.
>>
>> repeat {
>> // code
>> }
>>
>> vs
>>
>> repeat {
>> // code
>> } while true
>>
>
> What's wrong with `while true { }` ?
>
>
> This is a good question. In my opinion, nothing in and of itself, however
> since repeat is part of the language and it has a stand alone meaning in
> english,
>

"Repeat" in English does not mean "do something forever." It means "do
something one more time."


> it stands to reason that users will expect that it can stand alone just as
> do { } does. I would love to hear if this is a sentiment I alone have, or
> if others feel the same.
>
>
> The reason that the former is superior to the latter is that, given repeat
>> is already part of the language, the former it is simpler, with less noise.
>> It reads like simple english. It also aligns well with current do {}
>> syntax. This is the only argument I’m offering, and I think it’s the only
>> one that could be offered for such a small syntax change given that it
>> *only* serves to clarify and reduce noise of current syntax which has the
>> same functionality.
>>
>>
>> On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution <
>>> swift-evolution@swift.org> wrote:
>>>
>>> You could always do your control flow with goto’s anyway…
>>>
>>> func foo() {
>>>   var i = 0
>>>   func goto(_ label: String = "entry") {
>>> switch label {
>>> case "entry":
>>>   print("beginning loop…")
>>>   goto("cond")
>>> case "cond":
>>>   goto(i < 10 ? "body" : "end")
>>> case "body":
>>>   i += 1
>>>   print("\(i)")
>>>   goto("cond")
>>> case "end":
>>>   break
>>> default: break
>>> }
>>>   }
>>>   goto()
>>> }
>>>
>>> Apologies,
>>> Harlan
>>>
>>>
>>>
>>> And isn’t this the point really. Yes there are many different ways of
>>> doing something, but there should be one obvious way. IMHO, there is
>>> nothing more obvious than just
>>>
>>> repeat {
>>>
>>> }
>>>
>>> It’s very clear. It’s not about adding complex control flow, it’s about
>>> simplifying current syntax. I don’t think anyone is arguing that it’s more
>>> powerful than what while loops currently offer.
>>>
>>>
>>>
>>> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution <
>>> swift-evolution@swift.org> wrote:
>>>
>>> When I need a loop with complex control flow that does not fit into the
>>> classical while {} or repeat {} while structure, I use this:
>>>
>>> do_stuff: do {
>>>  …
>>>  continue do_stuff
>>> }
>>>
>>> This pattern explicit and allows very complex control flow patterns
>>> without the drawbacks of the unrestricted goto construct.
>>>
>>> Therefore I don’t see utility with having a repeat {} without while
>>> clause.
>>>
>>> Best,
>>>
>>> Taras
>>>
>>>
>>> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution <
>>> swift-evolution@swift.org> wrote:
>>>
>>>
>>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution <
>>> swift-evolution@swift.org> wrote:
>>>
>>> Secondly it’s a very simple way of introducing new programmers to loops.
>>> It’s IMHO more clear to a new programmer that repeat will just repeat
>>> indefinitely vs while true.
>>>
>>>
>>> This point seems strange to me - why teach a new programmer about loops
>>> by first showing them a looping construct they should probably never use in
>>> actual practice until they really know what they’re doing?
>>>
>>> totally agree… it would be a bad first introduction, id say :)
>>>
>>> ___
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 3:30 PM, Tyler Cloutier via swift-evolution <
swift-evolution@swift.org> wrote:

> I’d actually say that I’m strongly in favor of allowing just a repeat
> keyword, although I wouldn’t support making 'while true’.
>
> Firstly it reduces clutter
>

Can you explain what clutter you see? Unless I misunderstand what you're
referring to, reducing the 10 letters in `while true` to the six letters in
`repeat` is hardly "reducing clutter."


> and makes it very clear that the the code is just supposed to repeat.
>

I disagree here also. It is not very clear at all that the code is supposed
to repeat indefinitely, not to any audience.

First, it would not be clear to users who are experienced in Swift and
aware of this proposal. Code is meant to be read, and allowing the omission
of a trailing clause to produce two very different behaviors means that it
is not clear what `repeat {` means until you encounter the closing brace
and check for what follows. Moreover, what follows could be the keyword
`while` on the following line, and in that case you cannot know whether the
expression that follows `while` is the beginning of a new while loop until
you encounter or don't encounter a new opening brace. By contrast, `while
true {` cannot be anything other than the beginning of an infinite loop.
You already know that fact after reading 12 letters.

Second, it would not be clear to users migrating from another C-family
language. `while true { }` is immediately understood by users of any other
related language.

Third, it would not be clear based on a knowledge of English. In common
use, "repeat" does not mean repeat forever; it means to repeat once (i.e.
do something twice). If I ask you to repeat something you just said, I
should hope that you do not keep reciting it over and over until I tell you
to stop.


> Secondly it’s a very simple way of introducing new programmers to loops.
> It’s IMHO more clear to a new programmer that repeat will just repeat
> indefinitely vs while true.
>

I can speak to this a little bit, having introduced a new programmer to
loops very recently and having done so in the past as well. I have not
encountered anyone who has trouble with the *concept* of looping--i.e. the
idea that the same code can be run over and over.

Where things get tricky is the difficulty of mastering the syntax of the
while loop and, more problematic, the syntax of the classic for;; loop.
Introducing a simple way to make something repeat forever does not solve
this learning hurdle, because students will continue to have to contend
with these other types of loops in order to be productive in the language.
A special syntax for repeating forever is especially unhelpful because it
is just functional enough that a discouraged student may choose to avoid
learning other types of loops and instead combine the infinite loop with
if, continue, and break.


> Lastly, this isn’t the first time this has been brought up on this list
> and there was previously discussion about the fact that when people see the
> repeat keyword that it should naturally repeat indefinitely unless a where
> clause is specified.
>

I do believe that this is the first time this suggestion has been
introduced to the list. I do not recall any previous discussion focused on
infinite loops; they have been about repeating a finite number of times,
using proposed syntax such as `repeat 3 times { }` or variations on that
theme.


> I also think the concern that an accidental infinite loop is any greater
> than it is currently.
>

Code gets refactored and edited. We're discussing on another thread
changing the rules about dangling commas in parameter lists for that very
reason. If you try to move a block of code with a repeat...while loop but
accidentally leave behind the last line, this syntax will cause you grief.


> Tyler
>
>
>
> On May 10, 2016, at 1:09 PM, Erica Sadun via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> I do not see sufficiently measurable benefits to this proposal to add it
> to the language.
> It's easy enough to roll your own `repeatForever` function with trailing
> closure.
>
> I also want to thank you for bring it up on-list. Not every idea is right
> for Swift but it's
> always refreshing to see innovative thoughts added to the discussion.
> Please do not be
> discouraged by the generally negative feedback on this particular idea.
>
> -- Erica
>
> On May 10, 2016, at 1:27 AM, Nicholas Maccharoli via swift-evolution <
> swift-evolution@swift.org> 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 ... { b

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 2:50 PM, Xiaodi Wu  wrote:
> 
> 
> 
> On Tue, May 10, 2016 at 4:46 PM, Tyler Cloutier  > wrote:
> 
>> On May 10, 2016, at 2:34 PM, Xiaodi Wu > > wrote:
>> 
>> I think, on the contrary, it's missing the point utterly. It's up to those 
>> proposing a new feature to justify its addition in light of what's already 
>> here, and it's up to those proposing the removal of a feature to justify why 
>> it should be removed.
>> 
>> Certainly no one is proposing the removal of the while loop. Currently, the 
>> One Obvious Way of making an infinite loop is `while true`, and it is up to 
>> the proponents to advance a reason why a replacement would be superior. I 
>> cannot think of a greater non-sequitur than supplying a demonstration of why 
>> while loops are useful.
> 
> That’s what I am saying. No one is supplying a demonstration of why while 
> loops are useful and that suggestion is a straw man.
> 
> That was not meant to be a straw man, not on my part. It is my understanding 
> of Harlan's example. It shows that, without while loops, it is unwieldy to 
> express the same thing using goto statements. That is fine, but it is not at 
> all on point for this discussion.
>  
> My point below that simple and clear syntax is an improvement on syntax with 
> more noise.
> 
> repeat {
>   // code
> }
> 
> vs
> 
> repeat {
>   // code
> } while true
> 
> What's wrong with `while true { }` ? 

This is a good question. In my opinion, nothing in and of itself, however since 
repeat is part of the language and it has a stand alone meaning in english, it 
stands to reason that users will expect that it can stand alone just as do { } 
does. I would love to hear if this is a sentiment I alone have, or if others 
feel the same.

> 
> The reason that the former is superior to the latter is that, given repeat is 
> already part of the language, the former it is simpler, with less noise. It 
> reads like simple english. It also aligns well with current do {} syntax. 
> This is the only argument I’m offering, and I think it’s the only one that 
> could be offered for such a small syntax change given that it *only* serves 
> to clarify and reduce noise of current syntax which has the same 
> functionality.
> 
> 
>> On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> You could always do your control flow with goto’s anyway…
>>> 
>>> func foo() {
>>>   var i = 0
>>>   func goto(_ label: String = "entry") {
>>> switch label {
>>> case "entry":
>>>   print("beginning loop…")
>>>   goto("cond")
>>> case "cond":
>>>   goto(i < 10 ? "body" : "end")
>>> case "body":
>>>   i += 1
>>>   print("\(i)")
>>>   goto("cond")
>>> case "end":
>>>   break
>>> default: break
>>> }
>>>   }
>>>   goto()
>>> }
>>> 
>>> Apologies,
>>> Harlan
>> 
>> 
>> And isn’t this the point really. Yes there are many different ways of doing 
>> something, but there should be one obvious way. IMHO, there is nothing more 
>> obvious than just 
>> 
>> repeat {
>> 
>> }
>> 
>> It’s very clear. It’s not about adding complex control flow, it’s about 
>> simplifying current syntax. I don’t think anyone is arguing that it’s more 
>> powerful than what while loops currently offer.
>> 
>> 
>>> 
 On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution 
 mailto:swift-evolution@swift.org>> wrote:
 
 When I need a loop with complex control flow that does not fit into the 
 classical while {} or repeat {} while structure, I use this:
 
 do_stuff: do {
  …
  continue do_stuff
 } 
 
 This pattern explicit and allows very complex control flow patterns 
 without the drawbacks of the unrestricted goto construct. 
 
 Therefore I don’t see utility with having a repeat {} without while 
 clause. 
 
 Best, 
 
 Taras
 
 
> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> 
> 
>>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> Secondly it’s a very simple way of introducing new programmers to 
>>> loops. It’s IMHO more clear to a new programmer that repeat will just 
>>> repeat indefinitely vs while true.
>> 
>> This point seems strange to me - why teach a new programmer about loops 
>> by first showing them a looping construct they should probably never use 
>> in actual practice until they really know what they’re doing?
> totally agree… it would be a bad first introduction, id say :)
> 
> ___
> swift-evolution mailing list
> swift-e

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Eduardo Mourey Lopez Ne via swift-evolution
The only advantage that I see if of a repeat without a while true, is that the 
compiler could check for the presence of a break or give a warning 

repeat {
 //code
  if (check) {break} //will be required to avoid a warning 
}

repeat {
  //code
  //the user could forget to add a if break
} while true


> On May 10, 2016, at 4:50 PM, Xiaodi Wu via swift-evolution 
>  wrote:
> 
> 
> 
> On Tue, May 10, 2016 at 4:46 PM, Tyler Cloutier  > wrote:
> 
>> On May 10, 2016, at 2:34 PM, Xiaodi Wu > > wrote:
>> 
>> I think, on the contrary, it's missing the point utterly. It's up to those 
>> proposing a new feature to justify its addition in light of what's already 
>> here, and it's up to those proposing the removal of a feature to justify why 
>> it should be removed.
>> 
>> Certainly no one is proposing the removal of the while loop. Currently, the 
>> One Obvious Way of making an infinite loop is `while true`, and it is up to 
>> the proponents to advance a reason why a replacement would be superior. I 
>> cannot think of a greater non-sequitur than supplying a demonstration of why 
>> while loops are useful.
> 
> That’s what I am saying. No one is supplying a demonstration of why while 
> loops are useful and that suggestion is a straw man.
> 
> That was not meant to be a straw man, not on my part. It is my understanding 
> of Harlan's example. It shows that, without while loops, it is unwieldy to 
> express the same thing using goto statements. That is fine, but it is not at 
> all on point for this discussion.
>  
> My point below that simple and clear syntax is an improvement on syntax with 
> more noise.
> 
> repeat {
>   // code
> }
> 
> vs
> 
> repeat {
>   // code
> } while true
> 
> What's wrong with `while true { }` ? 
> 
> The reason that the former is superior to the latter is that, given repeat is 
> already part of the language, the former it is simpler, with less noise. It 
> reads like simple english. It also aligns well with current do {} syntax. 
> This is the only argument I’m offering, and I think it’s the only one that 
> could be offered for such a small syntax change given that it *only* serves 
> to clarify and reduce noise of current syntax which has the same 
> functionality.
> 
> 
>> On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> You could always do your control flow with goto’s anyway…
>>> 
>>> func foo() {
>>>   var i = 0
>>>   func goto(_ label: String = "entry") {
>>> switch label {
>>> case "entry":
>>>   print("beginning loop…")
>>>   goto("cond")
>>> case "cond":
>>>   goto(i < 10 ? "body" : "end")
>>> case "body":
>>>   i += 1
>>>   print("\(i)")
>>>   goto("cond")
>>> case "end":
>>>   break
>>> default: break
>>> }
>>>   }
>>>   goto()
>>> }
>>> 
>>> Apologies,
>>> Harlan
>> 
>> 
>> And isn’t this the point really. Yes there are many different ways of doing 
>> something, but there should be one obvious way. IMHO, there is nothing more 
>> obvious than just 
>> 
>> repeat {
>> 
>> }
>> 
>> It’s very clear. It’s not about adding complex control flow, it’s about 
>> simplifying current syntax. I don’t think anyone is arguing that it’s more 
>> powerful than what while loops currently offer.
>> 
>> 
>>> 
 On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution 
 mailto:swift-evolution@swift.org>> wrote:
 
 When I need a loop with complex control flow that does not fit into the 
 classical while {} or repeat {} while structure, I use this:
 
 do_stuff: do {
  …
  continue do_stuff
 } 
 
 This pattern explicit and allows very complex control flow patterns 
 without the drawbacks of the unrestricted goto construct. 
 
 Therefore I don’t see utility with having a repeat {} without while 
 clause. 
 
 Best, 
 
 Taras
 
 
> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> 
> 
>>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> Secondly it’s a very simple way of introducing new programmers to 
>>> loops. It’s IMHO more clear to a new programmer that repeat will just 
>>> repeat indefinitely vs while true.
>> 
>> This point seems strange to me - why teach a new programmer about loops 
>> by first showing them a looping construct they should probably never use 
>> in actual practice until they really know what they’re doing?
> totally agree… it would be a bad first introduction, id say :)
> 
> ___
> swift-evolution mailing list
> swift-evolution

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 4:46 PM, Tyler Cloutier 
wrote:

>
> On May 10, 2016, at 2:34 PM, Xiaodi Wu  wrote:
>
> I think, on the contrary, it's missing the point utterly. It's up to those
> proposing a new feature to justify its addition in light of what's already
> here, and it's up to those proposing the removal of a feature to justify
> why it should be removed.
>
> Certainly no one is proposing the removal of the while loop. Currently,
> the One Obvious Way of making an infinite loop is `while true`, and it is
> up to the proponents to advance a reason why a replacement would be
> superior. I cannot think of a greater non-sequitur than supplying a
> demonstration of why while loops are useful.
>
>
> That’s what I am saying. No one is supplying a demonstration of why while
> loops are useful and that suggestion is a straw man.
>

That was not meant to be a straw man, not on my part. It is my
understanding of Harlan's example. It shows that, without while loops, it
is unwieldy to express the same thing using goto statements. That is fine,
but it is not at all on point for this discussion.


> My point below that simple and clear syntax is an improvement on syntax
> with more noise.
>
> repeat {
> // code
> }
>
> vs
>
> repeat {
> // code
> } while true
>

What's wrong with `while true { }` ?

The reason that the former is superior to the latter is that, given repeat
> is already part of the language, the former it is simpler, with less noise.
> It reads like simple english. It also aligns well with current do {}
> syntax. This is the only argument I’m offering, and I think it’s the only
> one that could be offered for such a small syntax change given that it
> *only* serves to clarify and reduce noise of current syntax which has the
> same functionality.
>
>
> On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution <
> swift-evolution@swift.org> wrote:
>
>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>> You could always do your control flow with goto’s anyway…
>>
>> func foo() {
>>   var i = 0
>>   func goto(_ label: String = "entry") {
>> switch label {
>> case "entry":
>>   print("beginning loop…")
>>   goto("cond")
>> case "cond":
>>   goto(i < 10 ? "body" : "end")
>> case "body":
>>   i += 1
>>   print("\(i)")
>>   goto("cond")
>> case "end":
>>   break
>> default: break
>> }
>>   }
>>   goto()
>> }
>>
>> Apologies,
>> Harlan
>>
>>
>>
>> And isn’t this the point really. Yes there are many different ways of
>> doing something, but there should be one obvious way. IMHO, there is
>> nothing more obvious than just
>>
>> repeat {
>>
>> }
>>
>> It’s very clear. It’s not about adding complex control flow, it’s about
>> simplifying current syntax. I don’t think anyone is arguing that it’s more
>> powerful than what while loops currently offer.
>>
>>
>>
>> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>> When I need a loop with complex control flow that does not fit into the
>> classical while {} or repeat {} while structure, I use this:
>>
>> do_stuff: do {
>>  …
>>  continue do_stuff
>> }
>>
>> This pattern explicit and allows very complex control flow patterns
>> without the drawbacks of the unrestricted goto construct.
>>
>> Therefore I don’t see utility with having a repeat {} without while
>> clause.
>>
>> Best,
>>
>> Taras
>>
>>
>> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>>
>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>> Secondly it’s a very simple way of introducing new programmers to loops.
>> It’s IMHO more clear to a new programmer that repeat will just repeat
>> indefinitely vs while true.
>>
>>
>> This point seems strange to me - why teach a new programmer about loops
>> by first showing them a looping construct they should probably never use in
>> actual practice until they really know what they’re doing?
>>
>> totally agree… it would be a bad first introduction, id say :)
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swi

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 2:34 PM, Xiaodi Wu  wrote:
> 
> I think, on the contrary, it's missing the point utterly. It's up to those 
> proposing a new feature to justify its addition in light of what's already 
> here, and it's up to those proposing the removal of a feature to justify why 
> it should be removed.
> 
> Certainly no one is proposing the removal of the while loop. Currently, the 
> One Obvious Way of making an infinite loop is `while true`, and it is up to 
> the proponents to advance a reason why a replacement would be superior. I 
> cannot think of a greater non-sequitur than supplying a demonstration of why 
> while loops are useful.

That’s what I am saying. No one is supplying a demonstration of why while loops 
are useful and that suggestion is a straw man. My point below that simple and 
clear syntax is an improvement on syntax with more noise.

repeat {
// code
}

vs

repeat {
// code
} while true

The reason that the former is superior to the latter is that, given repeat is 
already part of the language, the former it is simpler, with less noise. It 
reads like simple english. It also aligns well with current do {} syntax. This 
is the only argument I’m offering, and I think it’s the only one that could be 
offered for such a small syntax change given that it *only* serves to clarify 
and reduce noise of current syntax which has the same functionality.


> On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> 
>> You could always do your control flow with goto’s anyway…
>> 
>> func foo() {
>>   var i = 0
>>   func goto(_ label: String = "entry") {
>> switch label {
>> case "entry":
>>   print("beginning loop…")
>>   goto("cond")
>> case "cond":
>>   goto(i < 10 ? "body" : "end")
>> case "body":
>>   i += 1
>>   print("\(i)")
>>   goto("cond")
>> case "end":
>>   break
>> default: break
>> }
>>   }
>>   goto()
>> }
>> 
>> Apologies,
>> Harlan
> 
> 
> And isn’t this the point really. Yes there are many different ways of doing 
> something, but there should be one obvious way. IMHO, there is nothing more 
> obvious than just 
> 
> repeat {
> 
> }
> 
> It’s very clear. It’s not about adding complex control flow, it’s about 
> simplifying current syntax. I don’t think anyone is arguing that it’s more 
> powerful than what while loops currently offer.
> 
> 
>> 
>>> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> When I need a loop with complex control flow that does not fit into the 
>>> classical while {} or repeat {} while structure, I use this:
>>> 
>>> do_stuff: do {
>>>  …
>>>  continue do_stuff
>>> } 
>>> 
>>> This pattern explicit and allows very complex control flow patterns without 
>>> the drawbacks of the unrestricted goto construct. 
>>> 
>>> Therefore I don’t see utility with having a repeat {} without while clause. 
>>> 
>>> Best, 
>>> 
>>> Taras
>>> 
>>> 
 On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
 mailto:swift-evolution@swift.org>> wrote:
 
 
>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> 
>> Secondly it’s a very simple way of introducing new programmers to loops. 
>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>> indefinitely vs while true.
> 
> This point seems strange to me - why teach a new programmer about loops 
> by first showing them a looping construct they should probably never use 
> in actual practice until they really know what they’re doing?
 totally agree… it would be a bad first introduction, id say :)
 
 ___
 swift-evolution mailing list
 swift-evolution@swift.org 
 https://lists.swift.org/mailman/listinfo/swift-evolution 
 
>>> 
>>> ___
>>> swift-evolution mailing list
>>> swift-evolution@swift.org 
>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>> 
>> 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> 

Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
I think, on the contrary, it's missing the point utterly. It's up to those
proposing a new feature to justify its addition in light of what's already
here, and it's up to those proposing the removal of a feature to justify
why it should be removed.

Certainly no one is proposing the removal of the while loop. Currently, the
One Obvious Way of making an infinite loop is `while true`, and it is up to
the proponents to advance a reason why a replacement would be superior. I
cannot think of a greater non-sequitur than supplying a demonstration of
why while loops are useful.
On Tue, May 10, 2016 at 16:27 Tyler Cloutier via swift-evolution <
swift-evolution@swift.org> wrote:

> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> You could always do your control flow with goto’s anyway…
>
> func foo() {
>   var i = 0
>   func goto(_ label: String = "entry") {
> switch label {
> case "entry":
>   print("beginning loop…")
>   goto("cond")
> case "cond":
>   goto(i < 10 ? "body" : "end")
> case "body":
>   i += 1
>   print("\(i)")
>   goto("cond")
> case "end":
>   break
> default: break
> }
>   }
>   goto()
> }
>
> Apologies,
> Harlan
>
>
>
> And isn’t this the point really. Yes there are many different ways of
> doing something, but there should be one obvious way. IMHO, there is
> nothing more obvious than just
>
> repeat {
>
> }
>
> It’s very clear. It’s not about adding complex control flow, it’s about
> simplifying current syntax. I don’t think anyone is arguing that it’s more
> powerful than what while loops currently offer.
>
>
>
> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> When I need a loop with complex control flow that does not fit into the
> classical while {} or repeat {} while structure, I use this:
>
> do_stuff: do {
>  …
>  continue do_stuff
> }
>
> This pattern explicit and allows very complex control flow patterns
> without the drawbacks of the unrestricted goto construct.
>
> Therefore I don’t see utility with having a repeat {} without while
> clause.
>
> Best,
>
> Taras
>
>
> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution <
> swift-evolution@swift.org> wrote:
>
>
> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> Secondly it’s a very simple way of introducing new programmers to loops.
> It’s IMHO more clear to a new programmer that repeat will just repeat
> indefinitely vs while true.
>
>
> This point seems strange to me - why teach a new programmer about loops by
> first showing them a looping construct they should probably never use in
> actual practice until they really know what they’re doing?
>
> totally agree… it would be a bad first introduction, id say :)
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution 
>  wrote:
> 
> You could always do your control flow with goto’s anyway…
> 
> func foo() {
>   var i = 0
>   func goto(_ label: String = "entry") {
> switch label {
> case "entry":
>   print("beginning loop…")
>   goto("cond")
> case "cond":
>   goto(i < 10 ? "body" : "end")
> case "body":
>   i += 1
>   print("\(i)")
>   goto("cond")
> case "end":
>   break
> default: break
> }
>   }
>   goto()
> }
> 
> Apologies,
> Harlan


And isn’t this the point really. Yes there are many different ways of doing 
something, but there should be one obvious way. IMHO, there is nothing more 
obvious than just 

repeat {

}

It’s very clear. It’s not about adding complex control flow, it’s about 
simplifying current syntax. I don’t think anyone is arguing that it’s more 
powerful than what while loops currently offer.


> 
>> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> 
>> When I need a loop with complex control flow that does not fit into the 
>> classical while {} or repeat {} while structure, I use this:
>> 
>> do_stuff: do {
>>  …
>>  continue do_stuff
>> } 
>> 
>> This pattern explicit and allows very complex control flow patterns without 
>> the drawbacks of the unrestricted goto construct. 
>> 
>> Therefore I don’t see utility with having a repeat {} without while clause. 
>> 
>> Best, 
>> 
>> Taras
>> 
>> 
>>> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
>>> mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> 
> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> 
> Secondly it’s a very simple way of introducing new programmers to loops. 
> It’s IMHO more clear to a new programmer that repeat will just repeat 
> indefinitely vs while true.
 
 This point seems strange to me - why teach a new programmer about loops by 
 first showing them a looping construct they should probably never use in 
 actual practice until they really know what they’re doing?
>>> totally agree… it would be a bad first introduction, id say :)
>>> 
>>> ___
>>> swift-evolution mailing list
>>> swift-evolution@swift.org 
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Harlan Haskins via swift-evolution
You could always do your control flow with goto’s anyway…

func foo() {
  var i = 0
  func goto(_ label: String = "entry") {
switch label {
case "entry":
  print("beginning loop…")
  goto("cond")
case "cond":
  goto(i < 10 ? "body" : "end")
case "body":
  i += 1
  print("\(i)")
  goto("cond")
case "end":
  break
default: break
}
  }
  goto()
}

Apologies,
Harlan

> On May 10, 2016, at 2:05 PM, Taras Zakharko via swift-evolution 
>  wrote:
> 
> When I need a loop with complex control flow that does not fit into the 
> classical while {} or repeat {} while structure, I use this:
> 
> do_stuff: do {
>  …
>  continue do_stuff
> } 
> 
> This pattern explicit and allows very complex control flow patterns without 
> the drawbacks of the unrestricted goto construct. 
> 
> Therefore I don’t see utility with having a repeat {} without while clause. 
> 
> Best, 
> 
> Taras
> 
> 
>> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
>>  wrote:
>> 
>> 
 On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
  wrote:
 
 Secondly it’s a very simple way of introducing new programmers to loops. 
 It’s IMHO more clear to a new programmer that repeat will just repeat 
 indefinitely vs while true.
>>> 
>>> This point seems strange to me - why teach a new programmer about loops by 
>>> first showing them a looping construct they should probably never use in 
>>> actual practice until they really know what they’re doing?
>> totally agree… it would be a bad first introduction, id say :)
>> 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
The proposed `repeat { }` is identical to `while true { }`. One of these
can happen accidentally because a trailing clause was unintentionally
omitted, while the other cannot. One of these currently exists in the
language, while the other does not. What is the motivation for having a new
way of doing the same thing? I have not seen an answer.


On Tue, May 10, 2016 at 4:05 PM, Taras Zakharko via swift-evolution <
swift-evolution@swift.org> wrote:

> When I need a loop with complex control flow that does not fit into the
> classical while {} or repeat {} while structure, I use this:
>
> do_stuff: do {
>   …
>   continue do_stuff
> }
>
> This pattern explicit and allows very complex control flow patterns
> without the drawbacks of the unrestricted goto construct.
>
> Therefore I don’t see utility with having a repeat {} without while clause.
>
> Best,
>
>  Taras
>
>
> > On 10 May 2016, at 22:39, Dominik Pich via swift-evolution <
> swift-evolution@swift.org> wrote:
> >
> >
> >>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution <
> swift-evolution@swift.org> wrote:
> >>>
> >>> Secondly it’s a very simple way of introducing new programmers to
> loops. It’s IMHO more clear to a new programmer that repeat will just
> repeat indefinitely vs while true.
> >>
> >> This point seems strange to me - why teach a new programmer about loops
> by first showing them a looping construct they should probably never use in
> actual practice until they really know what they’re doing?
> > totally agree… it would be a bad first introduction, id say :)
> >
> > ___
> > swift-evolution mailing list
> > swift-evolution@swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Taras Zakharko via swift-evolution
When I need a loop with complex control flow that does not fit into the 
classical while {} or repeat {} while structure, I use this:

do_stuff: do {
  …
  continue do_stuff
} 

This pattern explicit and allows very complex control flow patterns without the 
drawbacks of the unrestricted goto construct. 

Therefore I don’t see utility with having a repeat {} without while clause. 

Best, 

 Taras


> On 10 May 2016, at 22:39, Dominik Pich via swift-evolution 
>  wrote:
> 
> 
>>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>>>  wrote:
>>> 
>>> Secondly it’s a very simple way of introducing new programmers to loops. 
>>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>>> indefinitely vs while true.
>> 
>> This point seems strange to me - why teach a new programmer about loops by 
>> first showing them a looping construct they should probably never use in 
>> actual practice until they really know what they’re doing?
> totally agree… it would be a bad first introduction, id say :)
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Dominik Pich via swift-evolution

>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>>  wrote:
>> 
>> Secondly it’s a very simple way of introducing new programmers to loops. 
>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>> indefinitely vs while true.
> 
> This point seems strange to me - why teach a new programmer about loops by 
> first showing them a looping construct they should probably never use in 
> actual practice until they really know what they’re doing?
totally agree… it would be a bad first introduction, id say :)

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 1:34 PM, Sean Heber  wrote:
> 
>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>>  wrote:
>> 
>> Secondly it’s a very simple way of introducing new programmers to loops. 
>> It’s IMHO more clear to a new programmer that repeat will just repeat 
>> indefinitely vs while true.
> 
> This point seems strange to me - why teach a new programmer about loops by 
> first showing them a looping construct they should probably never use in 
> actual practice until they really know what they’re doing?

That is a fair point, but it’s probably a good way of illustrating other ways 
of exiting a loop, without having the complication of a while condition.

> 
> l8r
> Sean
> 

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution
I’d actually say that I’m strongly in favor of allowing just a repeat keyword, 
although I wouldn’t support making 'while true’.

Firstly it reduces clutter and makes it very clear that the the code is just 
supposed to repeat. 
Secondly it’s a very simple way of introducing new programmers to loops. It’s 
IMHO more clear to a new programmer that repeat will just repeat indefinitely 
vs while true.
Lastly, this isn’t the first time this has been brought up on this list and 
there was previously discussion about the fact that when people see the repeat 
keyword that it should naturally repeat indefinitely unless a where clause is 
specified.

I also think the concern that an accidental infinite loop is any greater than 
it is currently.

Tyler



> On May 10, 2016, at 1:09 PM, Erica Sadun via swift-evolution 
>  wrote:
> 
> I do not see sufficiently measurable benefits to this proposal to add it to 
> the language. 
> It's easy enough to roll your own `repeatForever` function with trailing 
> closure.
> 
> I also want to thank you for bring it up on-list. Not every idea is right for 
> Swift but it's
> always refreshing to see innovative thoughts added to the discussion. Please 
> do not be 
> discouraged by the generally negative feedback on this particular idea.
> 
> -- Erica
> 
>> On May 10, 2016, at 1:27 AM, Nicholas Maccharoli via swift-evolution 
>> mailto:swift-evolution@swift.org>> 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 
>> 
>> 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 { ... }`
>> 
>> I was thinking of drafting a short proposal if there was enough positive 
>> feedback. 
>> 
>> How does it sound?
>> 
>> - Nick 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Sean Heber via swift-evolution
> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution 
>  wrote:
> 
> Secondly it’s a very simple way of introducing new programmers to loops. It’s 
> IMHO more clear to a new programmer that repeat will just repeat indefinitely 
> vs while true.

This point seems strange to me - why teach a new programmer about loops by 
first showing them a looping construct they should probably never use in actual 
practice until they really know what they’re doing?

l8r
Sean

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Austin Zheng via swift-evolution
Sorry, I was trying to quote Haravikk but I didn't do it very clearly.

Austin

On Tue, May 10, 2016 at 1:32 PM, Tyler Cloutier 
wrote:

>
> On May 10, 2016, at 1:10 PM, Austin Zheng via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> Agreed. I'm not convinced that this actually prevents any more errors than
> it might cause (forgot to finish writing my "repeat" block, and now my app
> is unresponsive), and I don't think there's enough of an expressivity win
> to add another keyword.
>
>
> Certainly it’s not adding a new keyword, however it is changing the
> meaning of a keyword.
>
>
> Austin
>
> On Tue, May 10, 2016 at 1:04 PM, Haravikk via swift-evolution <
> swift-evolution@swift.org> wrote:
>
>>
>> On 10 May 2016, at 08:27, Nicholas Maccharoli via swift-evolution <
>> swift-evolution@swift.org> wrote:
>>
>> 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 }
>> //...
>> }
>>
>>
>> -1 from me on both counts; the thing I like about while true is that it’s
>> explicit about what I meant, whereas a repeat block with no while clause is
>> indistinguishable from me forgetting to include one, or me wanting an
>> infinite loop.
>>
>> An alternative could be to add a new “forever” keyword or something
>> similar, replacing while true wherever applicable, but personally I don’t
>> think it’s that important.
>>
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution
Furthermore, I also think it is a nice generalization of the 

do {

} 

syntax for scopes. I think it is quite intuitive that do executes a block once, 
and repeat executes it repeatedly.


> On May 10, 2016, at 1:09 PM, Erica Sadun via swift-evolution 
>  wrote:
> 
> I do not see sufficiently measurable benefits to this proposal to add it to 
> the language. 
> It's easy enough to roll your own `repeatForever` function with trailing 
> closure.
> 
> I also want to thank you for bring it up on-list. Not every idea is right for 
> Swift but it's
> always refreshing to see innovative thoughts added to the discussion. Please 
> do not be 
> discouraged by the generally negative feedback on this particular idea.
> 
> -- Erica
> 
>> On May 10, 2016, at 1:27 AM, Nicholas Maccharoli via swift-evolution 
>> mailto:swift-evolution@swift.org>> 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 
>> 
>> 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 { ... }`
>> 
>> I was thinking of drafting a short proposal if there was enough positive 
>> feedback. 
>> 
>> How does it sound?
>> 
>> - Nick 
>> ___
>> swift-evolution mailing list
>> swift-evolution@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 1:10 PM, Austin Zheng via swift-evolution 
>  wrote:
> 
> Agreed. I'm not convinced that this actually prevents any more errors than it 
> might cause (forgot to finish writing my "repeat" block, and now my app is 
> unresponsive), and I don't think there's enough of an expressivity win to add 
> another keyword.

Certainly it’s not adding a new keyword, however it is changing the meaning of 
a keyword.

> 
> Austin
> 
> On Tue, May 10, 2016 at 1:04 PM, Haravikk via swift-evolution 
> mailto:swift-evolution@swift.org>> wrote:
> 
>> On 10 May 2016, at 08:27, Nicholas Maccharoli via swift-evolution 
>> mailto:swift-evolution@swift.org>> wrote:
>> 
>> 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 }
>> //...
>> }
> 
> -1 from me on both counts; the thing I like about while true is that it’s 
> explicit about what I meant, whereas a repeat block with no while clause is 
> indistinguishable from me forgetting to include one, or me wanting an 
> infinite loop.
> 
> An alternative could be to add a new “forever” keyword or something similar, 
> replacing while true wherever applicable, but personally I don’t think it’s 
> that important.
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> 
> 
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Austin Zheng via swift-evolution
Agreed. I'm not convinced that this actually prevents any more errors than
it might cause (forgot to finish writing my "repeat" block, and now my app
is unresponsive), and I don't think there's enough of an expressivity win
to add another keyword.

Austin

On Tue, May 10, 2016 at 1:04 PM, Haravikk via swift-evolution <
swift-evolution@swift.org> wrote:

>
> On 10 May 2016, at 08:27, Nicholas Maccharoli via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> 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 }
> //...
> }
>
>
> -1 from me on both counts; the thing I like about while true is that it’s
> explicit about what I meant, whereas a repeat block with no while clause is
> indistinguishable from me forgetting to include one, or me wanting an
> infinite loop.
>
> An alternative could be to add a new “forever” keyword or something
> similar, replacing while true wherever applicable, but personally I don’t
> think it’s that important.
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Erica Sadun via swift-evolution
I do not see sufficiently measurable benefits to this proposal to add it to the 
language. 
It's easy enough to roll your own `repeatForever` function with trailing 
closure.

I also want to thank you for bring it up on-list. Not every idea is right for 
Swift but it's
always refreshing to see innovative thoughts added to the discussion. Please do 
not be 
discouraged by the generally negative feedback on this particular idea.

-- Erica

> On May 10, 2016, at 1:27 AM, Nicholas Maccharoli via swift-evolution 
>  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 
> 
> 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 { ... }`
> 
> I was thinking of drafting a short proposal if there was enough positive 
> feedback. 
> 
> How does it sound?
> 
> - Nick 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution
Oh you are right, I totally missed that, thanks.

> On May 10, 2016, at 12:10 PM, Xiaodi Wu  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  wrote:
>>> On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution 
>>>  wrote:
>>> 
 On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution 
  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
 swift-evolution@swift.org
 https://lists.swift.org/mailman/listinfo/swift-evolution
>>> 
>>> ___
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Haravikk via swift-evolution

> On 10 May 2016, at 08:27, Nicholas Maccharoli via swift-evolution 
>  wrote:
> 
> 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 }
> //...
> }

-1 from me on both counts; the thing I like about while true is that it’s 
explicit about what I meant, whereas a repeat block with no while clause is 
indistinguishable from me forgetting to include one, or me wanting an infinite 
loop.

An alternative could be to add a new “forever” keyword or something similar, 
replacing while true wherever applicable, but personally I don’t think it’s 
that important.___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread David Sweeris via swift-evolution
As am I. I like that the while clause can be optional, but I don't see the 
point of banning "while true".

- Dave Sweeris

> On May 10, 2016, at 14:10, Xiaodi Wu via swift-evolution 
>  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  wrote:
>>> On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution 
>>>  wrote:
>>> 
 On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution 
  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
 swift-evolution@swift.org
 https://lists.swift.org/mailman/listinfo/swift-evolution
>>> 
>>> ___
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
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  wrote:

> On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution <
> swift-evolution@swift.org> 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
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Tyler Cloutier via swift-evolution

> On May 10, 2016, at 12:39 AM, Xiaodi Wu via swift-evolution 
>  wrote:
> 
> On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution 
> mailto:swift-evolution@swift.org>> 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
> swift-evolution@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> 
> 
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> 
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Xiaodi Wu via swift-evolution
On Tue, May 10, 2016 at 2:27 AM, Nicholas Maccharoli via swift-evolution <
swift-evolution@swift.org> 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 was thinking of drafting a short proposal if there was enough positive
> feedback.
>
> How does it sound?
>
> - Nick
>
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


[swift-evolution] Change `repeat` to loop indefinitely if no while clause is present

2016-05-10 Thread Nicholas Maccharoli via swift-evolution
​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

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 { ... }`

I was thinking of drafting a short proposal if there was enough positive
feedback.

How does it sound?

- Nick
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution