<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>What is wrong with:</div><div><br></div><div>if let x = x where x &gt; 10, y != 5, let z = z where z != x</div><div><br></div><div>Just as a contrived example?</div><div><br></div><div>Brandon&nbsp;</div><div><br>On May 31, 2016, at 4:03 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 31, 2016 at 2:59 PM, Brandon Knope <span dir="ltr">&lt;<a href="mailto:bknope@me.com" target="_blank">bknope@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Except "b" is the main focus of the where clause and b was just in the preceding if condition.&nbsp;</div><div><br></div><div>I feel like we are trying to find ways to break the current where clause even though we've enjoyed it for almost a year now. I had no idea it was problematic and restrictive. I thought it made its intent very clear...leading to very readable code.&nbsp;</div><div><br></div><div>Pretty soon almost every construct but conditionals will be allowed to have where clauses, and THAT seems inconsistent to me.&nbsp;</div><div><br></div><div>...what exactly is the current problem? Can someone show me a real world example?? I've already forgotten it in all of this discussion -_-</div><div><br></div></div></blockquote><div><br></div><div>The origin of the problem is a simple question: how does one test for something unrelated to the variable that's bound in an `if let` statement? The answer is: in today's Swift, any such test after the first `let` must come after `where`. This is problematic and restrictive because one is forced to imply a semantic relationship that doesn't exist.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Brandon&nbsp;</div><div><div class="h5"><div><br>On May 31, 2016, at 3:47 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 31, 2016 at 2:45 PM, Christopher Kornher via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span><div><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>Not allowed:<br>…<br>let a = a<br>let b = b where b &gt; 10 &amp;&amp; a &gt; 5<br></blockquote><div><br></div><div>Why would this not be allowed by your rule? You're making use of `b` in your where clause. As I demonstrated above, essentially any assertion can be rewritten to work around your rule. In general:</div></div></div></div></div></blockquote><br></div></span><div>It is not allowed because &nbsp;‘a’ is defined in the line above. It must be defined in the ‘if let’ associated with the where in which it is mentioned.</div></div></blockquote><div><br></div><div>That's a much more restrictive where clause than you proposed earlier. You'd not be able to write:</div><div><br></div><div>```</div><div>let b = b where b &gt; anyOtherVariable</div><div>```&nbsp;</div></div><br></div></div>
</div></blockquote></div></div><span class=""><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></span></div></blockquote></div><br></div></div>
</div></blockquote></body></html>