<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="">A few quick points. Apologies for the brevity.</div><div class=""><br class=""></div><div class="">1. Please take a look at the stateful version of `sequence`</div><div class="">2. Additive, non-breaking proposals should be deferred until next month.</div><div class=""><br class=""></div><div class="">In regard to point 1, create a sequence that terminates on false. </div><div class="">So you can hack something up like this (of course, hopefully a little more elegant)</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> optionalPresentation: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures" class="">? { </span><span style="font-variant-ligatures: no-common-ligatures;" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ? </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class=""> : </span><span style="font-variant-ligatures: no-common-ligatures;" class="">nil</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">// a fake example of terminating check</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> doSomething() -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">arc4random_uniform</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) < </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">9</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// 10% chance of ending</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">for</span><span style="font-variant-ligatures: no-common-ligatures" class=""> nextItem </span><span style="font-variant-ligatures: no-common-ligatures;" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Swift.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">sequence</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span></div><div style="margin: 0px; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> state: </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">doSomething</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">().</span><span style="font-variant-ligatures: no-common-ligatures" class="">optionalPresentation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> next: { </span><span style="font-variant-ligatures: no-common-ligatures;" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">doSomething</span><span style="font-variant-ligatures: no-common-ligatures" class="">().</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">optionalPresentation</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }) {</span></div><p style="margin: 0px; line-height: normal; min-height: 19px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// use nextItem state here</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">// body of loop</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div></div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 18, 2016, at 11:52 AM, Braeden Profile 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><font face="Monaco" class="">Good morning, Swift community!</font><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class="">I’ve come across a situation a number of times where I write code that has to try something one or more times using a `repeat…while` loop and the condition relies upon variables that should be declared within the scope of the loop.</font></div><div class=""><br class=""></div><div class=""><font face="Monaco" class="">repeat</font></div><div class=""><font face="Monaco" class="">{</font></div><div class=""><span style="font-family: Monaco;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let success = doSomething()</span></div><div class=""><font face="Monaco" class="">}</font></div><div class=""><span style="font-family: Monaco;" class="">while !success</span></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class="">The compiler unnecessarily prohibits this: “Use of unresolved identifier four.” In this simple case, we can write:</font></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><div class=""><font face="Monaco" class="">repeat</font></div><div class=""><font face="Monaco" class="">{ </font><span style="font-family: Monaco;" class="">}</span></div><div class=""><span style="font-family: Monaco;" class="">while !</span><span style="font-family: Monaco;" class="">doSomething()</span></div></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class="">But in a more complex situation, we are forced to write:</font></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class="">var success: Bool</font></div><div class=""><div class=""><font face="Monaco" class="">repeat</font></div><div class=""><font face="Monaco" class="">{</font></div><div class=""><span style="font-family: Monaco;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>success = doSomething()</span></div><div class=""><font face="Monaco" class="">}</font></div><div class=""><span style="font-family: Monaco;" class="">while !success</span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="font-family: Monaco;" class="">We could change this so that the declarations within the top level scope of the loop are accessible from the condition.</span></div><div class=""><span style="font-family: Monaco;" class=""><br class=""></span></div><div class=""><span style="font-family: Monaco;" class="">Thanks for reading my first post to the Swift discussion board!</span></div><div class=""><span style="font-family: Monaco;" class="">—Braeden</span></div></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>