<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 see that this will help with consistency, this would address the question of when to use “then". &nbsp;I would not want to require it on statements. I like how you can simply put the brace after then condition in the existing Swift. It would be required for expression but not for statements. I can add this change if others like it too.<div class=""><br class=""></div><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 13, 2015, at 6:39 AM, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>&gt; 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="">Hi Paul,<div class=""><br class=""></div><div class="">thanks for gathering the ideas in a proposal!</div><div class=""><br class=""></div><div class="">You suggested to use if…then…else instead of just using the statement form if … {…} else {…}.</div><div class="">In that case I wonder whether it wouldn’t be better to use „then“ in if-statements as well for consistency:</div><div class=""><br class=""></div><div class=""><b class="">if</b> condition <b class="">then</b> {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>…</div><div class="">} <b class="">else</b> {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>…</div><div class="">}</div><div class=""><br class=""></div><div class="">For switch-expressions I’d just keep the statement syntax as there is only one pair of braces and not one per case. Separating the expressions, for which „then“ had to be introduced in case of the if-expression, is already done nicely by the „case“ keywords.&nbsp;</div><div class="">Here, too, my intent would be to keep the syntax of expression and statement the same for consistency.</div><div class=""><br class=""></div><div class="">Some remarks on the section about alternatives:</div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class="">The problem with this is that in expressions all cases must be handled. In a statement it is common to not have else. So you&nbsp;could make it an expression if the return value is used. This makes it more complex from both the user's perspective and the&nbsp;compiler perspective. That means that if you were to change a "if" conditional into an expression suddenly you would get an&nbsp;an error if the "else" part was not provided.<br class=""></blockquote></div><div class=""><br class=""></div><div class="">I don’t see any problem here. The only rule is that expressions have to have an else clause. This is independent of syntax i.e. whether we uses braces or „then".</div><div class=""><br class=""></div><div class="">Especially for the switch expression I don’t think the standard statement syntax with braces looks bad (as there is only one pair of braces around all cases and not one per case like in the if-statement), at least if you format it a little bit different than in your proposal and drop the unnecessary parentheses:<br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">let</span> color =</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(211, 54, 130);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">switch</span><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class=""> </span>enumColor<span style="font-variant-ligatures: no-common-ligatures; color: #839496" class=""> {</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">case</span> .Red:</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">switch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #d33682" class="">shade</span> {</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">case</span> .DarkRed: <span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">0xFFEEEE</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">case</span> .LightRed:&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">0xFF0000</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">default</span>: <span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">0xFF1010</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(41, 161, 152);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">default</span><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class="">: </span>0xFFFFFF</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class=""><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">-Thorsten</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">Am 13.12.2015 um 06:54 schrieb Paul Ossenbruggen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hello All,&nbsp;</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Been sick in bed all day, but decided to try to be productive…</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I did a rough draft of a proposal for implementing if expressions and switch expressions based upon the discussions we had here. I have tried to keep the scope of the changes as small as possible, &nbsp;only added one keyword and kept things as similar to the existing language constructs as possible. If anyone wants to help me with this, or has feedback, please let me know,</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="https://github.com/possen/swift-evolution/blob/master/0020.md" class="">https://github.com/possen/swift-evolution/blob/master/0020.md</a></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Thanks,</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">- Paul</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 12, 2015, at 3:51 PM, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Implied in using the &nbsp;“then", if…then…else would aways require “else" when using “then” similar to how “guard" requires “else”. This &nbsp;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.&nbsp;</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 12, 2015, at 12:59 PM, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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 &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">1. I would really hate to explain to someone when<span class="Apple-converted-space">&nbsp;</span><b class="">if</b><span class="Apple-converted-space">&nbsp;</span>needs a<span class="Apple-converted-space">&nbsp;</span><b class="">then</b><span class="Apple-converted-space">&nbsp;</span>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.&nbsp;</div></div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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><span class="Apple-converted-space">&nbsp;</span>A<span class="Apple-converted-space">&nbsp;</span><b class="">then</b><span class="Apple-converted-space">&nbsp;</span>B<span class="Apple-converted-space">&nbsp;</span><b class="">else</b><span class="Apple-converted-space">&nbsp;</span>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 class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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”&nbsp;</div><div class=""><br class=""></div><div class="">&nbsp;“say" then becomes an optional, *shudder*</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspev-2FF1wA41e1Hz2WJCh1c1Vo3Bd2K2p-2Fh239E3B9wInShnjxkINOEnOQiHF9I-2F9NRYqm8aNo1OhkLCSKJvlA8AbGOXvyvyK9CBZHGmrYa-2Fzv273hjJnZ3H89YjeZKqV70vvx0m4b1E-2BRp1dWtk38jfwB2vcWjec5aQveViNARA6z7vWoGGOQBUM8Fb9PrshEsY-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></div></div></div></blockquote></div><br class=""></div></div></body></html>