> On May 10, 2016, at 2:50 PM, Xiaodi Wu <xiaodi...@gmail.com> wrote: > > > > On Tue, May 10, 2016 at 4:46 PM, Tyler Cloutier <cloutierty...@aol.com > <mailto:cloutierty...@aol.com>> wrote: > >> On May 10, 2016, at 2:34 PM, Xiaodi Wu <xiaodi...@gmail.com >> <mailto:xiaodi...@gmail.com>> 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 >> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote: >>> On May 10, 2016, at 2:13 PM, Harlan Haskins via swift-evolution >>> <swift-evolution@swift.org <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 >>>> <swift-evolution@swift.org <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 >>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote: >>>>> >>>>> >>>>>>> On May 10, 2016, at 3:30 PM, Tyler Cloutier via swift-evolution >>>>>>> <swift-evolution@swift.org <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 <mailto:swift-evolution@swift.org> >>>>> https://lists.swift.org/mailman/listinfo/swift-evolution >>>>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >>>> >>>> _______________________________________________ >>>> swift-evolution mailing list >>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org> >>>> https://lists.swift.org/mailman/listinfo/swift-evolution >>>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >>> >>> _______________________________________________ >>> swift-evolution mailing list >>> swift-evolution@swift.org <mailto:swift-evolution@swift.org> >>> https://lists.swift.org/mailman/listinfo/swift-evolution >>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >> _______________________________________________ >> swift-evolution mailing list >> swift-evolution@swift.org <mailto:swift-evolution@swift.org> >> https://lists.swift.org/mailman/listinfo/swift-evolution >> <https://lists.swift.org/mailman/listinfo/swift-evolution> > >
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution