<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 don’t think adding <= which is really just a synonym for `return` would be inconsistent with current closure definitions.<div class=""><br class=""></div><div class="">case .Buy(leg quantity, let price) where quantity * price > 10000: </div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let vipCommissionRate = calculateCommissionRate(…)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>quantity * price * vipCommissionRate / 100</div><div class=""><br class=""></div><div class="">is a partial closure. Based on closure syntax you would be able to write it as a return or not (optional). If a specific team has a preference I would expect them to have something like a linter.</div><div class=""><br class=""></div><div class="">If we were consistent with closure syntax and not “case” syntax it would actually read “case …. in ….” but no one seemed to like it (my preference would have been “=>” or “->” instead of in which would be a much clear than “in”…. but that is not an option since it is not Swift syntax).</div><div class=""><br class=""></div><div class="">I personally don’t like the keyword “return” since it just seems so…. procedural…. (i.e. dating back to call …. subroutine….. return….). I guess each of us has hangups around silly little things…. (let still reminds me of horrid days of having to write visual basic code).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-17, at 2:32:11, Paul Ossenbruggen <<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In reviewing the proposal and looking at the statement form:<div class=""><br class=""></div><div class=""><div class=""><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * commissionRate / 100</div><div class="">}</div></div></div><br class="Apple-interchange-newline">I feel like it needs some syntax to indicate there is a return value for each case: </div><div class=""><br class=""></div><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * commissionRate / 100</div><div class="">}</div></div><div class=""><br class=""></div><div class="">it would enforce that there is only one <= for each and check that each result is the correct type to prevent errors where multiple return values are generated but the last one is ignored, I suppose that could be a warning though. This would only be used in the “case” form where multiple statements are used. Another option but we loose conciseness is to require return for multi statement expressions, but if you are doing multi statement, then you are probably not as concerned about conciseness:</div><div class=""><br class=""></div><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <font color="#9929bd" class="">return</font> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * commissionRate / 100</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>