<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="">-1 as well. This Int extension is super-easy to implement if you want it. I don't remember ever using it in code outside tutorials. </div><div class=""><br class=""></div><div class="">"What ought to be in the standard C++ library? One ideal is for a programmer to be able to find every interesting, significant, and reasonably general class, function, template, etc., in a library. However, the question here is not, "What ought to be in some library?" but "What ought to be in the standard library?" The answer "Everything!" is a reasonable first approximation to an answer to the former question but not the latter. A standard library is something every implementer must supply so that every programmer can rely on it" -- B. Strustroup</div><div class=""><br class=""></div><div class=""><ul class=""><li class=""><i class="">Would including this proposal in the Standard Library make a programmer's job easier?</i> Probably, but not often</li><li class=""><i class="">Does this proposal represent a fundamental element of daily development tasks? </i>In my opinion, no</li><li class=""><i class="">Does this proposal extend the core functionality of the language?</i> No</li><li class=""><i class="">Does this proposal deserve a place in an expended Standard Library?</i> No.</li></ul></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 4:18 PM, Kevin Ballard 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="">
<title class=""></title>
<div class=""><div class="">-1 here. It provides almost no utility outside of "hello world" style sample code. Also this particular method is ambiguous, as people have already said (the word "times" can mean multiplication just as much as it can mean looping), and it also doesn't even make much sense when used with non-literals, e.g. "foo.count.times" does not have the same "sounds like English" behavior that "5.times" does. More generally, we shouldn't be adding stuff to the standard library that doesn't provide any clear benefit, both because it's API bloat and because everybody has to pay for the code size.</div>
<div class=""> </div>
<div class="">-Kevin Ballrd</div>
<div class=""> </div>
<div class="">On Fri, Dec 18, 2015, at 10:25 AM, Cihat Gündüz via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">Dear Swift-Community,<br class=""></div>
<div class=""> </div>
<div class="">I’d like to propose an <b class="">addition of a useful method</b>, 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=""></div>
<div class=""> </div>
<div class="">For example recently in one of my projects I wanted to test the scalability of an important piece of code and wrote this method:<br class=""></div>
<div class=""> </div>
<div class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(187, 44, 162)">func</span> testPerfQualityInPercentWithoutQualityImprovements() {<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(49, 89, 93);" class=""><span class="colour" style=""></span><span class="colour" style="color:rgb(187, 44, 162)">self</span><span class="colour" style="">.</span>measureBlock<span class="colour" style=""> {</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(187, 44, 162)">let</span> expectedQuality = <span class="colour" style="color:rgb(39, 42, 216)">33.33</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(39, 42, 216)">0</span>.<span class="colour" style="color:rgb(61, 29, 129)">stride</span>(to: <span class="colour" style="color:rgb(39, 42, 216)">5_000</span>, by: <span class="colour" style="color:rgb(39, 42, 216)">1</span>).<span class="colour" style="color:rgb(61, 29, 129)">forEach </span>{ <span class="colour" style="color:rgb(187, 44, 162)">_</span> <span class="colour" style="color:rgb(187, 44, 162)">in</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(49, 89, 93)">XCTAssertEqualWithAccuracy</span>(<span class="colour" style="color:rgb(187, 44, 162)">self</span>.<span class="colour" style="color:rgb(79, 129, 135)">crossword</span>.<span class="colour" style="color:rgb(79, 129, 135)">qualityInPercent</span>, expectedQuality, accuracy: <span class="colour" style="color:rgb(39, 42, 216)">0.1</span>) <br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> } <br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> }<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> }<br class=""></div>
</div>
<div class=""> </div>
<div class="">As you can see what I basically wanted was to repeat the test some thousand times. I also like to use the Ruby language and one thing I love about it is that it has some really handy methods integrated to the language in situations like this which make the code very readable and therefore fun to use.<br class=""></div>
<div class=""> </div>
<div class="">I’m an even bigger fan of Swift so I’d love to see such useful methods appear in Swift, too and this is the first I came across that I really missed. So I’m asking myself, what if I could write the same code above like this:<br class=""></div>
<div class=""> </div>
<div class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(187, 44, 162)">func</span> testPerfQualityInPercentWithoutQualityImprovements() {<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(49, 89, 93);" class=""><span class="colour" style=""></span><span class="colour" style="color:rgb(187, 44, 162)">self</span><span class="colour" style="">.</span>measureBlock<span class="colour" style=""> {</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(187, 44, 162)">let</span> expectedQuality = <span class="colour" style="color:rgb(39, 42, 216)">33.33</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(39, 42, 216)">5_000.times {</span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="colour" style="color:rgb(49, 89, 93)">XCTAssertEqualWithAccuracy</span>(<span class="colour" style="color:rgb(187, 44, 162)">self</span>.<span class="colour" style="color:rgb(79, 129, 135)">crossword</span>.<span class="colour" style="color:rgb(79, 129, 135)">qualityInPercent</span>, expectedQuality, accuracy: <span class="colour" style="color:rgb(39, 42, 216)">0.1</span>) <br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> } <br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> }<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> }<br class=""></div>
</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">I think it could be added to the Swift standard library very easily (for example by using the .stride method like I used) without any side effects and has enough advantages to be part of Swift itself. What do you think?</span></span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">I wish you all the best,</span></span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Cihat</span></span><br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;" class=""> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class="">P.S.: This is my very first mail in such a mailing list so I did everything correctly. ^.^<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;line-height:normal;" class=""> </div>
<div class=""><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/1e0608548de1e4507ddf6418213e9ff58d394b90091dcd25b4bcb1017f1afb5a/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e416373637a466265433d6255375a6f42623a7f425663517e4e4268556d223244375c49393150313d2232403d614f456146483d2232477232587253645d66417b6746407731544972385e6d4f447b4240596a7358595e6b4076525a7c665a624866667746333d4c62586f62346d657948715947495440564444386156375d2232444d6543374a40537c6275427e667038484d22324a7a427d417744573533776b494b657d67514373575039337949335744316d40516448303d2232495f483d66575464337461384a665d22324266515d23344d23344/open" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div 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 class=""> </div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2d8HZsJEopZvt07Ik5MeNz0q8TYVQhS35YyDb6M37RXlkojPq2nvsIlnjazp-2FrFChm6Dz0Jutrp26ZhLYUWIZ1Zhgz6Og11-2FdLkDL2IdhouGOZhA3VF61UuS4YVdBddzHX23jXnv8nC1ho1c7Zb0Gh8GJM2kuzZFeZbDZj98ysbCPa6DEMde5AzAYsd7Gl0BFc-3D" 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;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>