<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><div class=""><div dir="ltr" class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 1 Jun 2016, at 02:47, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Q: How is an arbitrary boolean assertion introduced after `if let`?</div><div class=""><br class=""></div><div class="">Option 1 (present scenario)--using `where`</div><div class="">Advantages: expressive when it means exactly the right thing</div><div class="">Drawbacks: makes obligatory the suggestion of a semantic relationship between what comes before and after even when there is no such relationship</div></div></div></blockquote><div><br class=""></div><div>Like I said a little earlier, this drawback is not strictly true. No matter how unrelated to the binding a where clause may seemingly be, the binding is still dependent upon it; i.e- no value is bound if the condition fails, so regardless of what the condition is actually testing for it is very much related to the binding, like-so:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>if let value = foo where somethingUnrelatedIsTrue() { … }</font></div><div><br class=""></div><div>The variable named “value” doesn’t exist outside of this condition if somethingUnrelatedIsTrue() fails, so I’d say there is still very much a relationship between these two things. A lot of the time you probably <b class="">do</b> want to test the unwrapped value, but it’s not a requirement for the condition to be related, because one cannot succeed without the other.</div><div><br class=""></div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">Option 3--using a symbol never encountered in conditional statements (e.g. semicolon)</div><div class="">Advantages: doesn't need to be disambiguated from any existing uses</div><div class="">Drawbacks: looks out of place</div></div></blockquote><br class=""></div><div>How out of place does it really look? It’s no different from semi-colons for separating statements in code, and if where remains supported you’ll only need to use it in a handful of cases anyway (much like semi-colons for statement separation).</div></div></div></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">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:</div><div class=""><br class=""></div><div class="">`if let x = x where x < 3 { ... }` becomes</div><div class="">`if let x = x if x < 3 { ... }`</div><div class=""><br class=""></div><div class="">`while let item = sequence.next() where item > 0 { ... }` becomes</div><div class="">`while let item = sequence.next() while item > 0 { ... }`</div></div></div></blockquote><br class=""></div><div>I’m not sure what the difference is here; it doesn’t seem to have any capability that where doesn’t, surely it’s just changing the name of the keyword or is the point to have the full range of capabilities on both sides of the keyword? This could be done with where just as easily, no need for renaming, like so:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if let value = foo where case .Some(let value2) = bar { … }</font></div><div><br class=""></div><div>Bad example I know, but I don’t use pattern matching much. This currently doesn’t compile, but where could be extended to include all conditional types, so you could chain it to do pattern matching, conditional binding and a conditional all in one, is that the kind of thing you mean?</div></body></html>