<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="">Why not use a keyword? What if, the keyword 'returning' (or something like that) was used to specify the control flow behavior.</div><div class=""><br class=""></div><div class="">// Replaces ternary operator</div><div class="">let paint.color = returning if door.color == .Red { .Black } else { door.color }</div><div class=""><br class=""></div><div class="">// Supports additional conditions</div><div class="">let paint.finish = returning switch paint.color {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case .Black:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>.Matte</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case .White:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>.Eggshell</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>default:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>.Gloss</div><div class="">}</div><div class=""><br class=""></div><div class="">// Removes ambiguity of single statement behavior</div><div class="">let ages: [Int] = people.map returning { $0.age }</div><div class=""><br class=""></div><div class="">// Perhaps overreaching a bit</div><div class="">let label = returning UILabel(frame: CGRect.zero) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>.text = "Hello World"</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>.color = UIColor.red</div><div class="">}</div><div class=""><br class=""></div><div class="">I think it adds clarity without too much syntax bloat. I haven't thought out all the corner cases though, so maybe I'm missing something obvious.</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 4:56 PM, Chris Lattner 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=""><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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 12:17 PM, Per Melin &lt;<a href="mailto:p@greendale.se" class="">p@greendale.se</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Sat, Dec 5, 2015 at 7:15 PM, Chris Lattner <span dir="ltr" class="">&lt;<a href="mailto:clattner@apple.com" target="_blank" class="">clattner@apple.com</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Further, it is important to consider whether the code written using this will actually be *better* than the code written with these things as statements.&nbsp; For example, the “switch” blocks tend to be very large, and turning them into expressions encourages additional indentation.</blockquote><div class=""><br class=""></div><div class="">If you give functions implicit return at the same time – as in Haskell, Erlang, Scala, Rust, Ruby, Lisp/Scheme/Clojure, etc – &nbsp;there would be no need for additional indentation half of the time.</div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">This isn’t something that I’m personally interested in. &nbsp;I think that it is *feature* of swift that statements an declarations start with keywords. &nbsp;This greatly simplifies the grammar in various ways, and allows declmodifiers to be introduced without taking keywords space. &nbsp;</div><div class=""><br class=""></div><div class="">For example, relevant to this proposal, if/when we support “tail return foo()" for example, you don’t want to take “tail” as a keyword to make “tail foo()” work.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Not even Slava Pestov would factor Swift that aggressively.</div></div></div></div></blockquote><br class=""></div><div class="">Underestimating Slava is not a good idea! :-)</div><div class=""><br class=""></div><div class="">-Chris</div></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eABgjBqknOdLnwNfyLqbw6U-2BZOY4o2z70lPUq2Lz8gPaV-2BtZo3snpIUa63YT-2FUZ7qwktBbgDiqrJx0-2BuHU6WZH9qLPArfMNX8VuIaDxP5G2VNvIx-2F4oVZotJ-2BAguHQH-2FI6GVGOfMdWRhKTJwJmwmHY-2Bu4unCgotSeZ56Jc8-2B3ICLjGN7rp6fnQeR55fv8SFzDMGwxX3QyCd7aiVLkPdBgdcNbELXZte64dAcsSXrf-2BY-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=""></body></html>