<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 class="">Apologies for going off that tangent earlier.</div><br class=""><div><blockquote type="cite" class=""><div class="">On May 31, 2016, at 7:47 PM, Xiaodi Wu 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=""><div dir="ltr" class=""><div class="">Revisiting this conversation, it seems that most of the design space has been thoroughly explored. I think all suggestions presented so far boil down to these:</div><div class=""><br class=""></div><div class="">Q: How is an arbitrary boolean assertion introduced after `if let`?</div></div></div></blockquote><div><br class=""></div><div>Perhaps it is better to think in terms of starting with the boolean expression and then figure out where the case conditions and let clauses should fit-in.</div><div><br class=""></div><div>Starting with the simplest form: </div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if <boolean expression> </div><div><br class=""></div><div>add that it can be preceded by a single let clause:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if <b class="">let</b> <let list> <b class="">where </b><boolean expression> </div><div><div class=""><br class=""></div><div class="">where <let list> the comma separated list of assignments following a let</div><div class=""><br class=""></div><div class="">finishing up adding cases:</div><div class=""><br class=""></div><div class=""><div><span class="Apple-tab-span" style="white-space: pre;">        </span>if <b class="">let</b> <let list> <b class="">where </b><boolean expression> <b class="">case </b><case expression></div><div><br class=""></div><div>In this final form, '<boolean expression>’, '<b class="">let</b> <let list> <b class="">where’, </b>and <b class="">case </b><case expression> are all optional. One has to exist, of course.</div><div><br class=""></div><div>This standardizes the form in a sensible way, I think. So: a single ‘let’ and a single ‘case” are allowed, in the position shown.</div></div><div><br class=""></div><div>An example:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>'if let a=a, b=b, where (x==3 && y=x) || (x==2 && y!-=x) {…}'</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><br class=""></div></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><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 class=""><br class=""></div><div class="">Option 2--using a symbol sometimes encountered in conditional statements (e.g. `&&` or comma)</div><div class="">Advantages: doesn't look out of place</div><div class="">Drawbacks: needs to be disambiguated from existing uses, necessitating other changes in syntax</div><div class=""><br class=""></div><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></div></blockquote><div><br class=""></div><div>and it is equivalent to `&&` </div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>`if let a=a; x==3; y==4`</div><div><br class=""></div><div>is equivalent to</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>`if let a=a; x==3 && y==4`</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">For me, options 1 and 2 have permanent and objective drawbacks. By contrast, familiarity increases with time, and beauty is in the eye of the beholder.</div><div class=""><br class=""></div><div class="">* * *</div><div class=""><br class=""></div><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 class=""><br class=""></div><div class="">etc.</div><div class=""><br class=""></div><div class=""><br class=""></div>On Tue, May 31, 2016 at 2:00 PM, Erica Sadun <span dir="ltr" class=""><<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
> On May 31, 2016, at 12:52 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:<br class="">
> These lines of reasoning are what have compelled me to conclude that `where` might not be salvageable.<br class="">
<br class="">
</span>To which, I'd add: `where` suggests there's a subordinate and semantic relationship between the primary condition and the clause. There's no way as far as I know this to enforce it in the grammar and the proposal allows both clauses to be stated even without the connecting word. You could make a vague argument, I suppose, for renaming `where` to `when` but all in all, even killing `where` we benefit with better expressive capabilities and a simpler grammar.<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
-- E<br class="">
<br class="">
</font></span></blockquote></div><br class=""></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=""></body></html>