<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="">I don’t see the current way far <div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> optSel = <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt2"</span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><br class=""></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> optRes:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> = { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span> str{</div><p style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>case<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt1"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>case<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt2"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>default<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><p style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>} }()</div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 15px; line-height: normal;" class=""><font face="HelveticaNeue" class="">To beauty this maybe operators can come in downgrading eficiency:</font></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 15px; line-height: normal;" class=""><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> optSel = <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt2"</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal; min-height: 18px;" class=""><br class=""></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> optRes = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">optSel</span> *= [</div><p style="font-family: Menlo; margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt1"</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>),</div><div style="font-family: Menlo; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>(</span>"opt2"<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><p style="font-family: Menlo; margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="font-family: Menlo; margin: 0px; line-height: normal;" class="">] ?? <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><font face="HelveticaNeue" class="">With (pseudocode):</font></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class=""><br class=""></span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> *= (left: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>, right: [(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>)]) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>? {</div><div style="margin: 0px; line-height: normal; min-height: 18px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> (rightKey,rightValue) <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> right{</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> rightKey == left {</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> rightValue</div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>nil</div><div style="margin: 0px; line-height: normal;" class="">}</div></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class=""><br class=""></span></div></div><div class="">Or:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> optSel = <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"opt2"</span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><br class=""></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> optRes = optSel *= [</div><p style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>"opt1"<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,</span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>"opt2"<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span></div><p style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>] ?? <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span></div></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class=""><br class=""></span></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class=""><br class=""></span></div><div style="margin: 0px; font-size: 15px; line-height: normal;" class=""><font face="HelveticaNeue" class="">With (just conceptually):</font></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><font color="#272ad8" class=""><br class=""></font></div><div style="margin: 0px; font-size: 15px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> *= (left: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>, right: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Dictionary</span><<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>>) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Any</span>? {</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> rightKey <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> right.keys(){</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> rightKey == left {</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> right[rightKey]</div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><p style="margin: 0px; line-height: normal; min-height: 18px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>nil</div><div style="margin: 0px; line-height: normal;" class="">}</div></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">El 13 des 2015, a les 0:51, Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> va escriure:</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="">Implied in using the “then", if…then…else would aways require “else" when using “then” similar to how “guard" requires “else”. This will help to make the difference between statements and expressions clear.<div class=""><br class=""></div><div class="">let x = If cond then X else Y</div><div class=""><br class=""></div><div class="">is the full form, where “else" can not be omitted. </div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 12, 2015, at 12:59 PM, Paul Ossenbruggen <<a href="mailto:possen@gmail.com" class="">possen@gmail.com</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=""><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 12, 2015, at 12:37 PM, Andrey Tarantsov 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=""><div class="">1. I would really hate to explain to someone when <b class="">if</b> needs a <b class="">then</b> and when it doesn't. That's the sort of inconsistency that shouldn't be added lightly.</div></div></div></blockquote><div class=""><br class=""></div><div class="">agreed definitely want to be careful with that. I think with braces meaning statements that differentiation can be made clear. I would certainly start with statements when describing, just as you usually don’t talk about the ternary operator until later. </div></div><div class=""><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="">3. If we can somehow solve all of this, I think I'll be +1 for replacing (A ? B : C) with some sort of (<b class="">if</b> A <b class="">then</b> B <b class="">else</b> C).</div></div></div></blockquote><div class=""><br class=""></div>Yes that would be great.</div><div class=""><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=""><br class=""></div><div class="">4. Generally, I wonder how hard would it be for all statements to be usable as expressions? Why didn't Swift go that way from the start?</div></div></div></blockquote><div class=""><br class=""></div><div class="">The biggest problem statement is you don’t need to exhaustively specify every outcome:</div><div class=""><br class=""></div><div class="">if cond {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>print(“hello”)</div><div class="">}</div><div class=""><br class=""></div><div class="">whereas in an expression you have to specify what happens in the else.</div><div class=""><br class=""></div><div class="">let say = if cond then “hello” else “goodbye"</div></div><div class=""><br class=""></div><div class="">unless you go seriously off the deep end:</div><div class=""><br class=""></div><div class="">let say = if cond then “hello” </div><div class=""><br class=""></div><div class=""> “say" then becomes an optional, *shudder*</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHW0kAjxqiRekfpEJArOEyyrRg6GodtYhaXXmxHlwfJgo703CwPBrfFok0sXAMuMayW21bmGb8k9-2Bx8PG3xEiwE5MTrs7UIb8XgO-2Be-2FY3n4Yq1X-2BOd7W-2FLHOpthCyk4DCbEzfd1-2BzlSgvxPtnDvoFADkuW-2Bc7hPd0MGp7rqmo7HFAsCx3HXtib5cyhavoydWl0l3-2Fn3WyuTlvB9Fn0qE6moA-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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=""></div></div></body></html>