<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'm really confused by this proposal. Primarily it really seems to be asking for two things:<div class=""><br class=""></div><div class="">&nbsp; 1. Allow closures to skip the "switch item" line, and</div><div class="">&nbsp; 2. Implicit returns within closures</div><div class=""><br class=""></div><div class="">The desired troy example:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">let&nbsp;weightKg =&nbsp;weightTroy.reduce(0.00) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;(let&nbsp;acc, Troy.Pound(let&nbsp;quantity)):&nbsp;</font><span style="font-family: Menlo;" class="">acc + Double(quantity) *&nbsp;</span><span style="font-family: Menlo;" class="">0.373</span></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;(let&nbsp;acc, Troy.Ounce(let&nbsp;quantity)):&nbsp;</font><span style="font-family: Menlo;" class="">acc + Double(quantity) *&nbsp;</span><span style="font-family: Menlo;" class="">0.031103</span></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;(let&nbsp;acc, Troy.Pennyweight(let&nbsp;quantity)):&nbsp;</font><span style="font-family: Menlo;" class="">acc + Double(quantity) *&nbsp;</span><span style="font-family: Menlo;" class="">0.001555</span></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;(let&nbsp;acc, Troy.Grain(let&nbsp;quantity)):&nbsp;</font><span style="font-family: Menlo;" class="">acc + Double(quantity) *&nbsp;</span><span style="font-family: Menlo;" class="">0.0000648</span></div><div class=""><font face="Menlo" class="">}</font></div></blockquote><div class=""><br class=""></div><div class="">What you can already do today:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">let&nbsp;weightKg =&nbsp;weightTroy.reduce(0.00) { acc, troy&nbsp;in</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;switch&nbsp;troy {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;let&nbsp;.Pound(quantity):&nbsp;return&nbsp;acc +&nbsp;Double(quantity) *&nbsp;0.373</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;let&nbsp;.Ounce(quantity):&nbsp;return&nbsp;acc +&nbsp;Double(quantity) *&nbsp;0.031103</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;let&nbsp;.Pennyweight(quantity):&nbsp;return&nbsp;acc +&nbsp;Double(quantity) *&nbsp;0.001555</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;let&nbsp;.Grain(quantity):&nbsp;return&nbsp;acc +&nbsp;Double(quantity) *&nbsp;0.0000648</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;}</font></div><div class=""><font face="Menlo" class="">}</font></div></blockquote><div class=""><div class=""><br class=""></div><div class="">Unless I'm misunderstanding some other great value, this seems like a lot of syntax to save typing "switch troy" and "return". If you forget "return", the compiler will already error for you. I don't think the desired example brings more clarity either.</div><div class=""><br class=""></div><div class="">As to the initialization example:</div><div class=""><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Menlo" class="">let&nbsp;str:&nbsp;String&nbsp;= {</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;switch($0) {</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;.Cold:&nbsp;return&nbsp;"Too cold"</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;.Hot:&nbsp;&nbsp;return&nbsp;"Too hot"</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;default:&nbsp; &nbsp;&nbsp;return&nbsp;"Just right"</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;}</font></div></div><div class=""><div class=""><font face="Menlo" class="">}(state)</font></div></div></blockquote><div class=""><div class=""><br class=""></div><div class="">Yes, the type must be explicit because Swift cannot figure it out. I'd rather address that issue.</div><div class=""><br class=""></div><div class="">For me, I'm really not seeing the value the complexity of the proposal brings.</div><div class=""><br class=""></div><div class="">-David</div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 10:07 PM, Craig Cruden 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="">I will wait another 24 hours before resubmitting it (even though this discussion thread is not long)….&nbsp;<div class=""><br class=""></div><div class="">Anyone that had commented on this in the other thread, but not this one — it would be greatly appreciated if at least one comment (yay or nay) were added to this thread.</div><div class=""><br class=""></div><div class="">I think the last thread where this was discussed for at least 10 days and had many more comments - already fleshed everything out.</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-02-03, at 13:03:18, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.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="">Agreed. I really would like this to move forward.<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 6:59 PM, Denis Nikitenko 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="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;">+1 from me - I would like to see this discussion continue. &nbsp;Swift already recognizes the utility of pattern matching for initialization by retaining the ?: operator. &nbsp;It would be nice to see a more general and flexible solution that is still reasonably concise and doesn’t introduce new keywords and operators - though I’m sure at least some changes to the language would be inevitable. &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><br 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;"><div 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=""><blockquote type="cite" class=""><div class="">On Jan 29, 2016, at 1:43 AM, Craig Cruden 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="">The following proposal apparently was not considered widely enough discussed since it was “buried” in a 400 message discussion thread that meandered before coming to the final draft.</div><div class=""><br class=""></div><div class="">As such, to have it reopened — I am restarting the discussion in a new thread to ensure wider discussion.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><a href="https://github.com/cacruden/swift-evolution/blob/master/proposals/0024-Pattern-Matching-Partial-Function.md" class="">https://github.com/cacruden/swift-evolution/blob/master/proposals/0024-Pattern-Matching-Partial-Function.md</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><h1 class="" style="box-sizing: border-box; font-size: 2.25em; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.2; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; widows: 1; margin-top: 0px !important;">Pattern Matching Partial Function</h1></div></div></div></blockquote></div><div 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="">&lt;snip&gt;</div><br 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;"><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></blockquote></div><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=""></div></div></div></body></html>