<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’d be in favor of deferring this until other discussions about the ability to return/break/continue from closures play out. With that in place, there’s even the notion that for…in could be replaced by a library function. At that point, 5.times, or repeat(5) as a library call, would look a lot more attractive.</div><div class=""><br class=""></div><div class="">P</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 3:41 PM, Cihat Gündüz via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I agree with Radek. I find `for i in 5 { doSomething() }` or `for 5 { doSomething() }` to be very confusing since it is neither close to human language nor to any common programming language I know of.</span><div class="" style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I like the idea of giving students a step by step introduction into things, but this is IMO not the right way/place to do that.<div class=""><br class=""></div><div class="">– Cihat</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Am 18.12.2015 um 22:26 schrieb Radosław Pietruszewski via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra">An obvious question is, should it be equivalent to 1...n, or 0..<n?</div></div></blockquote><br class=""></div><div class="">I think that’s exactly why this isn’t a good idea. The semantics of `for i in 5` are not immediately clear at all.</div><div class=""><br class=""></div><div class="">If this was to be a language feature, `repeat 5`, suggested by Chris, seems like the least-ambiguous choice.</div><br class=""><div class=""><div class="">— Radek</div></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 18 Dec 2015, at 22:09, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra">This can be done pretty easily, although I think the approach has the potential to cause confusion elsewhere in code. An obvious question is, should it be equivalent to 1...n, or 0..<n?</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra">extension Int: SequenceType {</div><div class="gmail_extra"> public func generate() -> RangeGenerator<Int> {</div><div class="gmail_extra"> return (0..<self).generate()</div><div class="gmail_extra"> }</div><div class="gmail_extra">}</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">for i in 5 {</div><div class="gmail_extra"> print("hello \(i)")</div><div class="gmail_extra">}</div></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class="">Jacob Bandes-Storch<br class=""></div></div></div></div><br class=""><div class="gmail_quote">On Fri, Dec 18, 2015 at 1:03 PM, Brent Royal-Gordon via swift-evolution<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class="">> I’d like to propose an addition of a useful method, especially for beginners that also makes Swift much more readable in some situations: The addition of a .times method to Integer type(s).<br class=""><br class=""></span>I’ve said it before, but I don’t think `times` is a good solution for learners. It teaches them a form of looping they will never use in practice and does not allow them to practice with ancillary loop skills like `break` and `continue`.<br class=""><br class="">I think our best bet is to extend the `for` loop to allow a single number, meaning either `1…n` or `0..<n` (you can argue it either way), and also to allow the `variableName in` part to be omitted, meaning `_ in`. This gives us the pedagogical simplicity of a “do this N times” loop, but couches it in a form where, when the student moves on, more commonly used loop forms are a straightforward extension of that simple case.<br class=""><br class=""> for 5 { print(“Hello!”) }<br class=""> for i in 5 { print(“Hello \(i)!”) }<br class=""> for i in 10..<20 { print(“Hello \(i)!”) }<br class=""> for i in 10...20 { print(“Hello \(i)!”) }<br class=""><span class=""><font color="#888888" class=""><br class="">--<br class="">Brent Royal-Gordon<br class="">Architechies<br class=""></font></span><div class=""><div class="h5"><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=4hhvaxvZNsLrnZM9llg93kxoqfFYC8lhv8HAehOIDqLrRLXLvM2LNPW6bue1Bps4Vo1Wdz-2F9beNvMflXYUCh0lQ-2F7ChHyqU-2BvD38r-2BZJU1P1vQAgzDlFdGQo1S-2FPS8Wy-2F9L7To9LhJN81U0m7sP6u3V0q2JE7YG-2FimpmwA3T9uH8vPglAAc8EZYt32ohw2BfK-2B6nBw9xK0Ra1MjP5zBH-2BMnzBpWnxwUOoMYeEwMVB9Y-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"><span class="Apple-converted-space"> </span>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=aT-2FLnFEhPSFDSL7Gmx0xJo5o6hMhPoYO5Zn1SY30wfdDgl8FP4ay6Nj2vMOINKszIswxnwI5SsQYUXOVldWy26kN-2BpShzRnJbVMichO13fqHU7cPFhtwuCny4ONNfWmGwZeNCjoMTd41wBitZVCG3SxX6F0rLIbUXaRAtyTtCxCyPOfB-2Brq5AHzEOazG8ROAjexW1UJXHY7bHaWw4BjkvYNOOx-2BrNPERz7CN1l1F9dg-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=zCg-2FSGF9Wk188a6c55kLyEbrj7YhaXxFEHM-2F-2B0YAlzWUzZ0hO23R9Jywa2uZPmxQpim4uJzYmBohGZYA9NtcpXQZmOCKXvp1utlP1KN66WV08P6jfC10-2FNipqTdWp4GzPQzwJ-2Bocy277XCK8nGIdMcLLQkxUcHl48id5PaosROmtxdDclphhfycGtj0IYqdN1Vyh3d6KlaaPXE-2BmgAW3yObehPEJpgUGRT0e2HDJli8-3D" alt="" width="1" height="1" border="0" style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________</span><br style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: HelveticaNeue; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>