<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Jun 2016, at 21:15, Thorsten Seitz 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="">-1<div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Am 10.06.2016 um 21:10 schrieb Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; float: none; display: inline !important;" class="">if case .some(let Point.cartesian(x, y)) where x < y = json["rect"]?["origin"].flatMap(.init(rawValue:)) { … }</span></div></blockquote><br class=""></div><div class="">This: `where x < y = json[…]` is *very* unreadable and probably unparseable as it is missing a delimiter between the boolean expression and the expression behind the assignment operator. And I do not count the assignment operator as a sufficient delimiter.</div></div></div></div></blockquote><div><br class=""></div><div>This was why I mentioned parenthesis earlier, this example could be formatted more easily if the where clause moved into the case like so:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if case .some(let Point.cartesian(x, y) where x < y) = json[“rect”]?[“origin”].flatMap(.init(rawValue:)) { … }</font></div><div><br class=""></div><div>Though it’s probably a good candidate for spreading onto multiple lines in the first place, but I think that moving the where clause into the parenthesis clarifies its usage a bit if we <b class="">have</b> to move the where clause.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">I’ll give the following counterargument against this shuffling around of `where` or trying to eliminate it:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if case .some(let x) = someExpression where x > 0</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for x in xs where x > 0</div><div class=""><br class=""></div><div class="">These are actually very consistent in their grammar when you look at it like follows:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span><target> <assignment op> <source> where <condition></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if case .some(let x) = someExpression where x > 0</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>target: `case .some(let x)`</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>assignment op: `=`</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>source: `someExpression`</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>condition: `x > 0`</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>for x in xs where x > 0</div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>target: `x`</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>assignment op: `in`</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>source: `xs`</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>condition: `x > 0`</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">That is I’m arguing the `where` grammar is already quite regular and should not be changed. And yes, I’d like to have `where` back in `case`. And `let`.</div></div></div></div></div></blockquote></div><br class=""><div class="">Still, I’m inclined to agree with this. I find the where clause coming last pretty logical as I interpret it as reading like “complete this pattern match only if this condition is true”, or in the for loop “do the following only if this condition is true”, the latter could be clarified if we could write it as for x in xs where x > 0 do { … }, though that’s how I tend to read blocks to begin with (I’d just like to be able to use the do keyword to make it explicit).</div><div class=""><br class=""></div><div class="">The other thing I like about keeping the where clause at the end is that it keeps the fine detail to last, allowing the more significant action/intent to be described first. It’s tricky, there are merits to both options, but I’d say that trailing where is more consistent with the new trailing where on functions; this similarly lets you declare the most significant piece first, then fill in the details later.</div></body></html>