Coming up with a special way to return from closures/blocks is being discussed in the remove forEach thread. It may even need its own thread since it would affect so much of the language. <br><br>On Sunday, December 13, 2015, Andrew Brown via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>I agree, but there seems to be a lot of support for statements as expressions for some reason. That&#39;s not something I&#39;d be keen to move towards quickly but if we need to go there, how about a more general solution.</div><div><br></div><div>Let&#39;s give every statement a builtin &#39;return&#39; variable - I&#39;ll use _ in the example below but I don&#39;t think it&#39;s really appropriate. </div><div><br></div><div>let x = if condition {</div><div>    _ = value1</div><div>  } else {</div><div>    _ = value2</div><div>  }</div><div><br></div><div>let width = if condition {_ = 1920} else {_ = 640}</div><div><br></div><div>With a default assumption that _ = void if the default, if no assignments are used, we can ensure type checking and catch cases where not all paths correctly assign to _</div><div><br></div><div>ABR.</div><div><br>On 13 Dec 2015, at 18:37, Marc Knaup via swift-evolution &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Replacing constructs like<div><br></div><div><font face="monospace, monospace">let x = condition ? 0 : 1</font></div><div><br></div><div>with</div><div><br></div><div><font face="monospace, monospace">let x = if condition { 0 } else { 1 }</font></div><div><br></div><div>is very unlikely to make working with Swift any easier.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 13, 2015 at 7:18 PM, Dennis Lysenko <span dir="ltr">&lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;dennis.s.lysenko@gmail.com&#39;);" target="_blank">dennis.s.lysenko@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Just wanted to add, in regards to the argument of &quot;why use &#39;then&#39; rather than keeping &#39;if condition { A } else { B }&#39;?&quot;: besides my personal opinion that inline braces look out-of-place, braces behave specially in xcode and are notorious for screwing up indentation. For example, since swift was released, multiple non-trailing closure arguments to a single function call (e.g. MagicalRecord.saveWithBlock) are indented inconsistently, with the second closure one indentation level higher than the first. More generally/summarily, braces carry special indentation rules that do not necessarily suit expressions. </p><div><div>
<br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 13, 2015, 12:17 PM Paul Ossenbruggen via swift-evolution &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Dec 13, 2015, at 6:11 AM, Marc Knaup &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;marc@knaup.koeln&#39;);" target="_blank">marc@knaup.koeln</a>&gt; wrote:</div><br><div><div dir="ltr"><div>I also have no preference yet so I&#39;ll just throw in some thoughts.</div><div><br></div><div>** Existing Code **</div>The removal of the ternary operator would likely affect a lot of existing code.<div>A quick search for &quot; ? &quot; (with spaces) over a large app of our team yields 304 results.</div><div><br></div><div>Two simpler examples:</div><div><br></div><div><div><font face="monospace, monospace">[</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>&quot;With Conditions&quot;:            hasReport ? &quot;yes&quot; : &quot;no&quot;,</font></div><div><span style="font-family:monospace,monospace;white-space:pre-wrap">    </span><font face="monospace, monospace">&quot;With Image&quot;:                 hasImage ? &quot;yes&quot; : &quot;no&quot;,</font></div><div><span style="font-family:monospace,monospace;white-space:pre-wrap">    </span><font face="monospace, monospace">&quot;With Message&quot;:               hasMessage ? &quot;yes&quot; : &quot;no&quot;,</font></div><div><span style="font-family:monospace,monospace;white-space:pre-wrap">    </span><font face="monospace, monospace">&quot;Shared on Facebook Profile&quot;: sharedOnFacebookProfile ? &quot;yes&quot; : &quot;no&quot;,</font></div><div><span style="font-family:monospace,monospace;white-space:pre-wrap">    </span><font face="monospace, monospace">&quot;Shared in Facebook Group&quot;:   sharedOnFacebookGroup ? &quot;yes&quot; : &quot;no&quot;,</font></div><div><span style="font-family:monospace,monospace;white-space:pre-wrap">    </span><font face="monospace, monospace">&quot;Shared on Facebook Page&quot;:    sharedOnFacebookPage ? &quot;yes&quot; : &quot;no&quot;</font></div><div><font face="monospace, monospace">]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">view1.alpha = editing ? 1 : 0</font></div><div><font face="monospace, monospace">view2.alpha = editing ? 1 : 0</font></div><div><font face="monospace, monospace">view3.alpha = editing ? 0 : 1</font></div><div><font face="monospace, monospace">view4.alpha = editing ? 1 : 0</font></div></div><div><font face="monospace, monospace"><br></font></div><div>I am not sure using <font face="monospace, monospace">if…then…else</font> would make this better to read &amp; understand or worse.</div><div><br></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>there seems to be a lot of people who dislike ternary operators. Other languages also are similar in dumping ternary. </div></div></div><div style="word-wrap:break-word"><div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>** Keyword <font face="monospace, monospace">then</font> **</div><div>Making then a keyword would also cost us another word so that change needs to be carefully considered.</div><div>In our large app I found just a single instance where <font face="monospace, monospace">then</font> was used for a variable&#39;s name:</div><div><span><br></span></div><div><font face="monospace, monospace"><span>func</span><span> reloadConfigurationAndThen(then: </span><span>() -&gt; Void</span><span>) { … }</span></font><br></div><div><p>Promises use the word <font face="monospace, monospace">then</font> rather extensively: <a href="https://promisesaplus.com/" target="_blank">https://promisesaplus.com</a></p></div></div><div class="gmail_extra"><br></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>Good point. Will think about it.</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">On Sun, Dec 13, 2015 at 2:45 PM, Matthew Johnson via swift-evolution <span dir="ltr">&lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</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>I&#39;m not quite sure how I feel about this specific proposal yet but in general I do want to see conditional expressions and removal of the ternary operator.</div><div><br></div><div>I would like to see &quot;else if&quot; included in whatever we adopt as the final solution.  Is there a reason this is omitted from this proposal?  I apologize if that was discussed in the thread.  I haven&#39;t followed every post. </div><div><br>Sent from my iPad</div><div><div><div><br>On Dec 12, 2015, at 11:54 PM, Paul Ossenbruggen via swift-evolution &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div>Hello All, </div><div><br></div><div>Been sick in bed all day, but decided to try to be productive…</div><div><br></div>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,  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,<div><br></div><div><a href="https://github.com/possen/swift-evolution/blob/master/0020.md" target="_blank">https://github.com/possen/swift-evolution/blob/master/0020.md</a></div><div><br></div><div>Thanks,</div><div>- Paul</div><div><br><div><br></div><div><br><div><blockquote type="cite"><div>On Dec 12, 2015, at 3:51 PM, Paul Ossenbruggen &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;possen@gmail.com&#39;);" target="_blank">possen@gmail.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">Implied in using the  “then&quot;, if…then…else would aways require “else&quot; when using “then” similar to how “guard&quot; requires “else”. This  will help to make the difference between statements and expressions clear.<div><br></div><div>let x = If cond then X else Y</div><div><br></div><div>is the full form, where “else&quot; can not be omitted. </div><div><br></div><div><blockquote type="cite"><div>On Dec 12, 2015, at 12:59 PM, Paul Ossenbruggen &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;possen@gmail.com&#39;);" target="_blank">possen@gmail.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div><br></div><br><div><blockquote type="cite"><div>On Dec 12, 2015, at 12:37 PM, Andrey Tarantsov via swift-evolution &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div>1. I would really hate to explain to someone when <b>if</b> needs a <b>then</b> and when it doesn&#39;t. That&#39;s the sort of inconsistency that shouldn&#39;t be added lightly.</div></div></div></blockquote><div><br></div><div>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><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div>3. If we can somehow solve all of this, I think I&#39;ll be +1 for replacing (A ? B : C) with some sort of (<b>if</b> A <b>then</b> B <b>else</b> C).</div></div></div></blockquote><div><br></div>Yes that would be great.</div><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div>4. Generally, I wonder how hard would it be for all statements to be usable as expressions? Why didn&#39;t Swift go that way from the start?</div></div></div></blockquote><div><br></div><div>The biggest problem statement is you don’t need to exhaustively specify every outcome:</div><div><br></div><div>if cond {</div><div><span style="white-space:pre-wrap">        </span>print(“hello”)</div><div>}</div><div><br></div><div>whereas in an expression you have to specify what happens in the else.</div><div><br></div><div>let say = if cond then “hello” else “goodbye&quot;</div></div><div><br></div><div>unless you go seriously off the deep end:</div><div><br></div><div>let say = if cond then “hello” </div><div><br></div><div> “say&quot; then becomes an optional, *shudder*</div><div><br></div><div><br></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAdaxSAa57vVHzgOaGS3OJDr3kBSrQQ4LUow9XMreNnGSkOltVnJB1w7eSPQnCmAvsg-2FfCzxFcek37a-2BVd36PwEHGh5EqvhIo948Lr1lsgWaCdBXwEZxt6-2BFwdHf7roCv-2F1jb2h2r9BYeyHnOlSA-2BxOALuCbwUKtpnI70jPXFQaFh8-2Bwfx46L-2FVM8zbpCeQa-2FtE-3D" alt="" width="1" height="1" border="0" style="min-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">

</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><span><br><span>swift-evolution mailing list</span><br><span><a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" 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></span></div></blockquote>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=6ZGE61OxINd5lLe2xYh9Ku-2BXbixWNr2nvfzp2IB1sZgyGF-2BKGEpH8nn4D8Nw9i1XMnAD61AsGp8lQXFbag-2B6f7gZMz4Y125guAxWdpK4sebTv2UR83D2z3MoDfJqPgYYLT8PQro5mflcoUeHIfCy9gmPG7uWpAeZrG9bFFYa-2BoA4Ym7T0eS7LN3So9yrU8aM-2BTGW4cClyytnOzkfreJ-2BFmO62uZeJ2asIjEBfH6rhFg-3D" alt="" width="1" height="1" border="0" style="min-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">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPcBc4gRDCcGfh5bX5mRukUKvcoWY6YCxLBdsTP5BnJleKjRCFBhLs6nzUoN5ZhF8g-2BcEJr9Apac5RTzgcnMnHW4CwJC4iXK98zkBCJ6LSlDICvEq3dOPAVhPvNib-2B1z4BksKD8CVRm4OU1Jx45m-2BrI2PrVDbcbqwL74FCx8lCxW7QGWd82fc4pajPbEc3Aal3k-3D" alt="" width="1" height="1" border="0" style="min-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">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=XyCJWhfMItFjSNmahITOc-2BaLdcEkFSkNIDwJ912yGxF3UiiG2e5CDyS6l-2B-2Btc2MfUJIhAxmOdR9doYGOV6GVDOFBi9Sjdyvoam8MfkkuWg2xkqFegM1-2F7QI1PL1fwrMu7jfrCO-2BVNNr7DcKFEc6FeaMBL94i7yF3i7jcHWygMutkKhNutLrEYDcbDL6FFhV6BjR1bd662HkF4DhO-2FXQVtQ-3D-3D" alt="" width="1" height="1" border="0" style="min-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">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;swift-evolution@swift.org&#39;);" 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>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=OWK4tSasaK2n-2FQIIcS9Ug-2FuFXG-2BJ3z6cFMLgm306hDfGn49KPBKcNGf6n-2F3V4F56OWswzH7AFgGNAihH1-2FyxLe8noJbVDe02N6OUwf-2B8baKui9F8GgNn6HSxPGrVxobf-2BLuo5RuHVOQCMbFD078NMM5Ghc9rUK6UnpXLmoH2dBoyHExZ4i79Ve06JUH-2BPtUOcahqJAXJnmXBr87Ph2NVt1RpbyS3IvjNS1OGYBkwpsM-3D" alt="" width="1" height="1" border="0" style="min-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">
</div>
</blockquote>