<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Why not define a times() or timesRepeat() method on Int taking a closure to execute multiple times, like Erica recently posted and which is common in other languages like Ruby, Smalltalk or (I think) Scala:</div><div><br></div><div>5.times { ... }</div><div><br></div><div>or&nbsp;</div><div><br></div><div>5.timesRepeat { ... }</div><div><br></div><div>That reads quite naturally and does not need any language extension.</div><div><br></div><div>-Thorsten&nbsp;</div><div><br>Am 09.12.2015 um 06:58 schrieb Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">On Dec 8, 2015, at 4:43 PM, Daniel Steinberg via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<div><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; 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=""></div><div style="font-family: Helvetica; font-size: 12px; 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="">For me this comes up when teaching children or new programmers. (Perhaps not a valid use case)</div></div></blockquote><div><br class=""></div><div>This is a very valid use case.</div><div><br class=""></div><div>FWIW, “repeat N {}” was originally designed and scoped into the Swift 2 implementation of the feature, but was cut due to schedule limitations. &nbsp;There is precedent for this sort of feature in many teaching oriented languages (e.g. Logo).</div><div><br class=""></div><div>I’d say that the pro’s and con’s of this are:</div><div><br class=""></div><div>+ Makes a simple case very simple, particularly important in teaching.</div><div>+ Even if you aren’t familiar with it, you can tell at first glance what the behavior is.</div><div>- It is “just syntactic sugar”, which makes the language more complex.</div><div>- It is a very narrow feature that is useful in few practical situations.</div><div><br class=""></div><div>-Chris</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Z0lfE0AvBRKWSDAcltP5-2FwA6tH7CtZqjBw6KQdxzh8UeEAuMESPncyStoaIO7wH-2B24hXT1ZMKGUnu-2BTz8YJ5z26FiiBFoAgwDYSO4KMGVZdqr63t1OV-2F2gsfSSGMcpKJJeZNk0ncCNDtw5qp6bf-2FMWnDzFjD7ewlON-2FymcyDZrCe0g8sgWYwhx9vtb517ekoGOJ8ZTl6MV4rgytCBhILGz80xi-2Bd7m8FRMP29x7msSdrUfB2-2FMcWhuG3d52hGkqr" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>