<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="">So the solution to everything in the proposal is to create a mutable variable and then a bunch of if statements in inverse format?</div><div class=""><br class=""></div><div class="">Then take that and embed in a “pure” function where you need closures? </div><div class=""><br class=""></div><div class="">And forget about pattern matching and decomposing enums?</div><div class=""><br class=""></div><div class="">And this is the solution to “all”?</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-29, at 16:09:19, James Campbell 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 dir="auto" class=""><div class="">I think all of this could be solved by just having postfix if statements</div><div class=""><br class=""></div><div class="">var str: String?</div><div class=""><br class=""></div><div class="">str = "hot" if state == .Hot</div><div class="">str = "cold" if state == .Cold</div><div class=""><br class=""></div><div class="">//if the ??= operator proposal is accepted then we could just do:</div><div class="">str ??= "Invalid Temperature"</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">This is used a lot in Ruby, more flexible since it could be used on any line of code, flexible and concise. I think it reads quite well so beginners will grasp it easily (as I did when writing my first Ruby)</div><div class=""><br class=""></div><div class="">I think compiler wise it could be treated like a do while loop except it only loops once ;) </div><div class=""><br class=""><div class="">Sent from my iPhone</div></div><div class=""><br class="">On 29 Jan 2016, at 08:06, Charles Constant via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Sorry for the barrage here, Paul :)</div><div class=""><br class=""></div><div class=""><span style="font-size:13px" class="">> I’m not even convinced the new syntax is clearer so much as cleverer.</span><br class=""></div><div class=""><br class=""></div>As I've followed the various threads for switch-like assignments, I've been thinking a lot about how valid it is to say that more explicit is all that helpful to beginners. I wish I had the resources to test these assumptions with actual people who had never written Swift.<br class=""><div class=""><br class=""></div><div class="">As an example. </div><div class=""><br class=""></div><div class="">We assume that this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(35, 35, 35);" class=""> <span style="color:rgb(50,62,125)" class="">let</span> phrase: <span style="color:rgb(88,126,168)" class="">String</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" class=""><span style="color:rgb(35,35,35)" class=""> </span><span style="color:rgb(50,62,125)" class="">switch</span><span style="color:rgb(35,35,35)" class="">( </span>temperature <span style="color:rgb(35,35,35)" class="">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> <span style="color:rgb(50,62,125)" class="">case</span> .Cold: <span style="color:rgb(88,126,168)" class="">str</span> = <span style="color:rgb(132,62,100)" class="">"Too cold"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> <span style="color:rgb(50,62,125)" class="">case</span> .Hot: <span style="color:rgb(88,126,168)" class="">str</span> = <span style="color:rgb(132,62,100)" class="">"Too hot"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> <span style="color:rgb(50,62,125)" class="">default</span>: <span style="color:rgb(88,126,168)" class="">str</span> = <span style="color:rgb(132,62,100)" class="">"Just right"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> }</div></div><div class=""><br class=""></div><div class="">is going to be easier for beginners than something like this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(35, 35, 35);" class=""> <span style="color:rgb(50,62,125)" class="">let</span> phrase = <span style="color:rgb(88,126,168)" class="">temperature</span> ?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> <span style="color:rgb(132,62,100)" class="">"Too cold" </span><span style="color:rgb(35,35,35)" class="">if </span>.Cold :</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80);" class=""> <span style="color:rgb(132,62,100)" class="">"Too hot” </span><span style="color:rgb(35,35,35)" class="">if</span><span style="color:rgb(132,62,100)" class=""> </span>.Hot :</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(132, 62, 100);" class=""><span style="color:rgb(80,13,80)" class=""> </span>"Just right" <span style="color:rgb(35,35,35)" class="">if _ </span><span style="color:rgb(80,13,80)" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(80, 13, 80); min-height: 13px;" class=""><br class=""></div></div><div class=""><div class="">I'm using a short version here that is not the actual proposal, and that we won't use (since we don't want to overload "if"). But I have a strong hunch that a beginner is not going to find the longer version any more clear. There's a lot of syntax for the programmer to parse in the "switch" statement, as it stands. I suspect the less redundancy we have, the easier it is to figure out what is going on.</div></div><div class=""><br class=""></div><div class=""><br class=""></div></div>
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></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>