<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 12 Dec 2015, at 19:33, J. Cheyo Jimenez <<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="">There are a couple of languages that use then inside their switches. </span><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="http://rigaux.org/language-study/syntax-across-languages.html#CntrFlowMltSlcSwt" class="">http://rigaux.org/language-study/syntax-across-languages.html#CntrFlowMltSlcSwt</a><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="">I like using only one then in the switch to signal to the parser that this is a switch expression</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="">The only issue I see is that the colon in the switch is used in the same way as the current ternary expression. </div></div></blockquote><div><br class=""></div><div>Good point. This probably makes more sense:</div><div><br class=""></div><div><div>let y = switch c {</div><div> .Red then 1</div><div> .Green then 2</div><div> .Blue then 3</div><div>}</div></div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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="">Personally I don't think that a switch expression is all that useful since being a multiline statement actually helps the readability. </div></div></blockquote></div><br class=""><div class="">I think it can cut down on unnecessary boilerplate code, especially in functions that contain pattern matching and return a value. In which case you need to declare a variable, do the switch, assign to the var, then return at the end. It’s possible to do the trick with wrapping the switch in a closure inside the function, but that’s also quite ugly. It’d be nice to be able to do:</div><div class=""><br class=""></div><div class=""><div class="">func f(c: Col) -> Int {</div><div class=""> return switch c {</div><div class=""> .Red then 1</div><div class=""> .Green then 2</div><div class=""> .Blue then 3</div><div class=""> }</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>