<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 like this too, seems more powerful. Also, would single line expressions be allowed? If not would case be required for example:<div class=""><br class=""></div><div class=""><div class=""><div dir="ltr" class=""><div class="">let myFavoriteColor = yourFavoriteColor ?</div><div class=""> case .Blue: .Red</div><div class=""> case .Green: .Blue</div><div class=""> case .Red: .Green</div><div class=""> default: .Yellow</div></div></div><div class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div></div></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 9:11 AM, Sean Heber 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 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="">I really like this train of thought. +1<br class=""><br class="">l8r</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="">Sean<br class=""><br class=""></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=""><br class="">On Dec 6, 2015, at 11:02 AM, Alex Lew via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" 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=""><div class=""><div dir="ltr" class="">What if we left the if { ...} else { ... } syntax alone (as a statement), and updated the ternary expression to be a more general pattern matching expression (closer to "switch")? Something like<div class=""><br class=""></div><div class="">let x = condition ?</div><div class=""> true: "Hello"</div><div class=""> false: "Goodbye"</div><div class=""><br class=""></div><div class="">let x = optionalValue ?</div><div class=""> .Some(let unwrapped): "Hello, \(unwrapped)"</div><div class=""> .None: "To Whom It May Concern"</div><div class=""><br class=""></div><div class="">let myFavoriteColor = yourFavoriteColor ?</div><div class=""> .Blue: .Red</div><div class=""> .Green: .Blue</div><div class=""> .Red: .Green</div><div class=""><br class=""></div><div class="">let quadrant = (x, y) ?</div><div class=""> let (x, y) where x < 50 && y < 50: "top left"</div><div class=""> let (x, y) where x < 50 && y > 50: "bottom left"</div><div class=""> let (x, y) where x > 50 && y < 50: "top right"</div><div class=""> default: "bottom right"</div><div class=""><br class=""></div><div class="">The colon comes from the fact that this is sort of a light-weight expression-based "switch" statement, where each branch can only contain an expression, not a series of statements.</div><div class=""><br class=""></div><div class="">This is very similar to pattern matching expressions in languages like Haskell, ML, and Coq.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Dec 6, 2015 at 11:25 AM, Thorsten Seitz<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:thorsten.seitz@web.de" target="_blank" class="">thorsten.seitz@web.de</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><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;"><div style="word-wrap: break-word;" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">Am 06.12.2015 um 01:28 schrieb Alex Lew via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>>:</div><br class=""><div class=""><div dir="ltr" class="">I don't think you can just get rid of the if statement in favor of an expression. You still want to be able to do this:<div class=""><br class=""></div><div class="">if (condition) {</div><div class=""> funcWithSideEffectsThatReturnsInt()</div><div class="">} else {</div><div class=""> funcWithSideEffectsThatReturnsString()</div><div class="">}</div><div class=""><br class=""></div><div class="">but that's not a valid expression (what is its type?).</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">That would actually be no problem if Swift’s type system would have union types (Ceylon has union and intersection types which are quite awesome and enable lots of nice things quite naturally, see<span class="Apple-converted-space"> </span><a href="http://ceylon-lang.org/documentation/1.2/tour/types/" target="_blank" class="">http://ceylon-lang.org/documentation/1.2/tour/types/</a>).</div><div class=""><br class=""></div><div class="">In that case the type of such an expression would just be the union of both types, which is written<span class="Apple-converted-space"> </span><font face="Courier" class="">Int | String</font><span class="Apple-converted-space"> </span>in Ceylon.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-Thorsten</div></font></span></div><br class=""></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CzM39owGTpkJ1zyGXnrRVEXja65D5KHvjV3-2BNib8-2FAJ7I-2BJbfRxXmDRCHnuhR0WtlpTLnWdI2Y6IyX0tw-2Fw9N8tF-2B9G-2BRk-2BL-2B8GKHIk81vp2y21aeTAHjiIZtgY1KFL-2FvTp5Fjk8N5GThn-2Bh6K3QIsaXRpD0zvWu-2FLZA12AesmIVJa3GomIeG0SB0cEEddFnPUJ03D2yc06KuD7pNpGDAbbrq32AXZfpSe71d4-2Fc5s4-3D" alt="" width="1" height="1" border="0" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div></blockquote><blockquote type="cite" 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=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwwfs6LTY-2BMPtZmxwhX42OIgKPST0vif-2BJNOCc2zmBGkpdzeyKry-2BIDz2OVXHG-2BiQvmm-2B41dX32M5FJNISHG6lBkjIwBQ0tZ8Bti2u-2BfSDjj04w7LVRU8FVngzLK2coij8bI0UPC314-2BvEJVGbLjwM9zdRXKfsiBG-2FNP9KDTh2FHDGbY-2BXGVvAck53Yid94SSP4-3D" alt="" width="1" height="1" border="0" 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; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" 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=""><span class="Apple-converted-space"> </span>_______________________________________________</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></body></html>