<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>From the original thread:<br><br></div><div><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Am 01.06.2016 um 03:47 schrieb Xiaodi Wu via swift-evolution <<a dir="ltr" href="mailto:swift-evolution@swift.org" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="1">swift-evolution@swift.org</a>>:<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><snip><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">It does occur to me that there is one more option. I don't know that I like it, but it's an option no one has put forward before: recite the opening keyword when beginning a new boolean expression:<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">`if let x = x where x < 3 { ... }` becomes<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">`if let x = x if x < 3 { ... }`<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">`while let item = sequence.next() where item > 0 { ... }` becomes<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">`while let item = sequence.next() while item > 0 { ... }`<br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">etc.</span></font></blockquote><blockquote type="cite"></blockquote><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br>I've almost had the same idea... However I would not replace "where" rather than using if/while/guard as delimiters for new optional bindings/case-conditions:<br><br>// if ----------------------<br></span></font></div><div><span style="background-color: rgba(255, 255, 255, 0);">if let x = y where x < 4,</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">if case let .some(a) = b where a > 42 {<br> ...<br>}</span></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br>// Is equivalent to:<br><br>if let x = y where x < 4 {<br> if case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 {<br> ...<br> }<br>}<br><br><br>// guard ----------------------<br>guard let x = y where x < 4,</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">guard case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 else { ... }<br><br>// Is equivalent to:<br><br>guard let x = y where x < 4 else { ... }<br>guard case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 else { ... }<br><br><br><br>// while ----------------------<br><br>// "guard" or "if" should probably be used as delimiter instead of "while"<br>// since it is not a nested loop (imo I would go with "if"... discussable...)<br>while let x = y where x < 4,</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">while case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 {<br> ...<br>}<br><br>// Is equivalent to:<br><br>while let x = y where x < 4 {<br> guard case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 else {<br> break<br> }<br> do { ... }<br>}<br><br>// or with if<br><br>while let x = y where x < 4 {<br> if case let .</span></font><span style="background-color: rgba(255, 255, 255, 0);">some</span><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">(a) = b where a > 42 {<br> ...<br> } else { break }<br>}<br><br><br><br>Note that all these statements have a nice symmetry to their "long form". These statements can also be similarly written without introducing a new scope and code duplication in else branches:<br><br>if ...<br>if ... {<br> ...<br>} else { ... }<br><br>vs<br><br>if ... {<br> if ... {<br> ...<br> } else { ... }<br>} else { ... }<br><br><br>Best regards<br>Maximilian</span></font></div></body></html>