<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="">One complication with allowing postfix conditionals for all statements is that it often needs to have an else clause as well (like the ternary operator “?:").</div><div class=""><br class=""></div><div class="">For example, what’s the type of “x” below?</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> someCriteria()</span></div></div><div class=""><br class=""></div><div class="">And is “y” initialized or not?</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> y: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">42</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> someCriteria()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">doSomething(with: y)</span></div></div><div class=""><br class=""></div><div class="">I realize that this idea is more about the feature/behavior than the naming, but renaming “guard” to “unless” is one of the commonly rejected proposals.</div><div class=""><a href="https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md" class="">https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md</a></div><div class=""><br class=""></div><div class="">- David</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 04 Aug 2016, at 16:52, Kurt Werle 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="">Why would you do this just for return statements? Why not do postfix conditionals for all statements (like ruby)?<div class=""><br class=""></div><div class="">I've always liked postfix conditionals, but not enough to suggest them. Mostly I'm curious about limiting the scope to return statements.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Aug 4, 2016 at 7:31 AM, Christian Kienle via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">+1</div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">2016-08-04 15:38 GMT+02:00 Julian Dunskus via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span>:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="h5"><div style="word-wrap:break-word" class="">How often have you written something like the following?<div class=""><br class=""></div><div class="">`</div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#b51b47" class="">if</span><span class=""> indexPath.row == </span><span style="color:#7373ff" class="">0</span><span class=""> { </span><span style="color:#b51b47" class="">return</span><span class=""> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#b51b47" class="">guard</span><span class=""> </span><span style="color:#b51b47" class="">let</span><span class=""> thing = things[index] </span><span style="color:#b51b47" class="">else</span><span class=""> { </span><span style="color:#b51b47" class="">return nil</span><span class=""> }</span></div></div><div class="">`</div><div class=""><br class=""></div><div class="">I propose adding some syntactic sugar to make such statements more readable and simple to write:</div><div class=""><br class=""></div><div class="">`</div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#b51b47" class="">return</span><span class=""> </span><span style="color:#b51b47" class="">if</span><span class=""> indexPath.row == </span><span style="color:#7373ff" class="">0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#b51b47" class="">return</span><span class=""> </span><span style="color:#b51b47" class="">nil</span><span class=""> <span style="color:rgb(181,27,71)" class="">unless</span> </span><span style="color:#b51b47" class="">let</span><span class=""> thing = things[</span><span style="color:#cc4428" class="">index</span><span class="">]</span></div></div><div class="">`</div><div class=""><br class=""></div><div class="">I don’t know how easy or hard this would be to implement, but I think it would improve some code significantly.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">–Julian Dunskus</div></font></span></div><br class=""></div></div>_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div data-smartmail="gmail_signature" class=""><div dir="ltr" class=""><font face="arial, helvetica, sans-serif" style="font-size:12.8000001907349px" class="">Mit freundlichen Grüßen</font><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><br class=""></font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><b class="">Christian Kienle</b></font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Mobile Developer</font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><br class=""></font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><b class="">REWE Digital GmbH</b></font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Domstraße 20, 50668 Köln, Büro: Schanzenstr. 6-20, 51063 Köln</font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Geschäftsführer: Dr. Jean-Jacques Michel van Oosten (Vorsitzender), Christoph Eltze, Dr. Johannes Steegmann, Dr. Robert Zores</font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Handelsregister: Amtsgericht Köln (HRB 78670) UST-ID-Nr.: DE 290 605 450</font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><br class=""></font></div><div class=""><font face="arial, helvetica, sans-serif" style="font-size:12.8000001907349px" class="">Telefon: +49 </font><font face="arial, helvetica, sans-serif" class="">151 11441782</font></div><div style="font-size:12.8000001907349px" class=""><span style="font-family:arial,helvetica,sans-serif;font-size:12.8000001907349px" class="">E-Mail: </span><a href="mailto:christian.kienle@rewe-digital.com" style="font-family:arial,helvetica,sans-serif;font-size:12.8000001907349px;color:rgb(17,85,204)" target="_blank" class="">christian.kienle@rewe-digital.com</a><br class=""></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Internet: <u class=""><a href="http://www.rewe-digital.com/" style="color:rgb(17,85,204)" target="_blank" class="">www.rewe-digital.com</a></u></font></div><div style="font-size:12.8000001907349px" class=""><br class=""></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class="">Ein Unternehmen der <b class="">REWE GROUP</b></font></div><div style="font-size:12.8000001907349px" class=""><font face="arial, helvetica, sans-serif" class=""><a href="http://www.rewe-group.com/" style="color:rgb(17,85,204)" target="_blank" class="">http://www.rewe-group.com</a></font></div></div></div>
</div>
<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><a href="mailto:kurt@circlew.org" class="">kurt@CircleW.org</a><br class=""><a href="http://www.circlew.org/kurt/" target="_blank" class="">http://www.CircleW.org/kurt/</a><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>