<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="">This is definitively something very useful but it also introduces a strong asymmetry into Swift statements. In all control-flow statements, the condition is part of the outer scope. Or, to be more precise, its part of an intermediate scope between the outer and the inner scope (as you can declare variables in the condition which are invisible to the outer scope but visible to the inner scope). Your suggestion essentially moves the condition of repeat {} while () to the inner scope. I think that the more complex semantics is not worth the change.&nbsp;<div class=""><br class=""></div><div class="">Here is how I deal with it btw:</div><div class=""><br class=""></div><div class="">process: do {</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;let success = …</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;guard success else { continue process }</div><div class="">}</div><div class=""><br class=""></div><div class="">Again, goto FTW :p</div><div class=""><br class=""></div><div class="">T.<br class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Jul 2016, at 19:52, Braeden Profile via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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 =&nbsp;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: &nbsp;“Use of unresolved identifier four.” &nbsp;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="">{&nbsp;</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 =&nbsp;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=""></div></div></body></html>