<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Ostensibly, case may not be necessary if you could delimit each case on one line with something (perhaps a comma, or something else if that would not fit well within the grammar):<br></div>
<div> </div>
<div>let thisColor = thatColor ? .Blue: .Red, .Green: .Blue, .Red: .Green, default: .Yellow<br></div>
<div> </div>
<div>On Sun, Dec 6, 2015, at 01:57 PM, Paul Ossenbruggen via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>I like this too, seems more powerful. Also, would single line expressions be allowed? If not would case be required for example:<br></div>
<div> </div>
<div><div><div dir="ltr"><div>let myFavoriteColor = yourFavoriteColor ?<br></div>
<div> case .Blue: .Red<br></div>
<div> case .Green: .Blue<br></div>
<div> case .Red: .Green<br></div>
<div> default: .Yellow<br></div>
</div>
</div>
<div><div><div dir="ltr"><div> </div>
</div>
</div>
</div>
<div><div> </div>
<div><blockquote type="cite"><div>On Dec 6, 2015, at 9:11 AM, Sean Heber via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div> </div>
<div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><div>I really like this train of thought. +1<br></div>
<div> </div>
<div>l8r<br></div>
</div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><div>Sean<br></div>
</div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><div> </div>
<div>On Dec 6, 2015, at 11:02 AM, Alex Lew via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" type="cite"><div><div dir="ltr"><div>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<br></div>
<div> </div>
<div>let x = condition ?<br></div>
<div> true: "Hello"<br></div>
<div> false: "Goodbye"<br></div>
<div> </div>
<div>let x = optionalValue ?<br></div>
<div> .Some(let unwrapped): "Hello, \(unwrapped)"<br></div>
<div> .None: "To Whom It May Concern"<br></div>
<div> </div>
<div>let myFavoriteColor = yourFavoriteColor ?<br></div>
<div> .Blue: .Red<br></div>
<div> .Green: .Blue<br></div>
<div> .Red: .Green<br></div>
<div> </div>
<div>let quadrant = (x, y) ?<br></div>
<div> let (x, y) where x < 50 && y < 50: "top left"<br></div>
<div> let (x, y) where x < 50 && y > 50: "bottom left"<br></div>
<div> let (x, y) where x > 50 && y < 50: "top right"<br></div>
<div> default: "bottom right"<br></div>
<div> </div>
<div>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.<br></div>
<div> </div>
<div>This is very similar to pattern matching expressions in languages like Haskell, ML, and Coq.<br></div>
</div>
<div><div> </div>
<div><div>On Sun, Dec 6, 2015 at 11:25 AM, Thorsten Seitz<span></span><span dir="ltr"><<a href="mailto:thorsten.seitz@web.de">thorsten.seitz@web.de</a>></span><span></span>wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left: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;"><div><div> </div>
<blockquote type="cite"><div><span>Am 06.12.2015 um 01:28 schrieb Alex Lew via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:</span><br></div>
<div> </div>
<div><div dir="ltr"><div><span>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:</span><br></div>
<div> </div>
<div><span>if (condition) {</span><br></div>
<div><span> funcWithSideEffectsThatReturnsInt()</span><br></div>
<div><span>} else {</span><br></div>
<div><span> funcWithSideEffectsThatReturnsString()</span><br></div>
<div><span>}</span><br></div>
<div> </div>
<div><span>but that's not a valid expression (what is its type?).</span><br></div>
</div>
</div>
</blockquote><div> </div>
<div> </div>
<div>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></span><a href="http://ceylon-lang.org/documentation/1.2/tour/types/">http://ceylon-lang.org/documentation/1.2/tour/types/</a>).<br></div>
<div> </div>
<div>In that case the type of such an expression would just be the union of both types, which is written<span></span><span style="font-family:Courier" class="font">Int | String</span><span></span>in Ceylon.<br></div>
<div> </div>
<div> </div>
<div><span><span style="color:rgb(136, 136, 136)" class="colour">-Thorsten</span></span><br></div>
<div> </div>
</div>
<div> </div>
</div>
</blockquote></div>
<div> </div>
</div>
<div><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-right:0px !important;margin-bottom:0px !important;margin-left:0px !important;padding-top:0px !important;padding-right:0px !important;padding-bottom:0px !important;padding-left:0px !important;" alt="" src="https://www.fastmailusercontent.com/proxy/c37e5dc3a8f3d561b31011c23312a2f88559e802d2123d6f608523d08b72d0eb/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d334a7d43393f677744507b6a413a7977485e62725655485a61663534453b48467a66533d22324e4962683d2236414a47394d22324a42666258785d644253484e6578625037547c60745c4e6754694239563949785034777d223647793e4834764d223249374d2232425b6d22324c4d223248374b48494b683136707239723131656451484a69694a547769513b464c4d223646745075364a6b683e453744586e6d223248663b433159437168525074403a7677557d22364c4a5141323145637d69465a4163374f6d694567403352403365454464664e60555a40333442397360363b457447307e4077444142626271733231485a56607355673134643d2236436533743d23344/open" border="0" height="1" width="1"><br></div>
</div>
</blockquote><blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" type="cite"><div><div><span>_______________________________________________</span><br></div>
<div><span>swift-evolution mailing list</span><br></div>
<div><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br></div>
<div><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div>
</div>
</blockquote><div><img style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-right:0px !important;margin-bottom:0px !important;margin-left:0px !important;padding-top:0px !important;padding-right:0px !important;padding-bottom:0px !important;padding-left:0px !important;" alt="" src="https://www.fastmailusercontent.com/proxy/f5db77d743b9e6bcbe0444f92042db08e1374678a99825a9640c97409029eafc/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d356d6279486e60513869466736364f687876743e4e4a41585d22364758636a7e6543577b42435774413d4547777663763c44595d22324d40547a5d6877786854323f49476b405354503679666d22324a4e4f4343623a7d62474b60746a75697b42797d223249444a723f465858474d22324961567d6d6d22324431346853323d45364a4e49435847463c624b6a6947724150347a5832447962357d22324663544a6a603437773c4652555836465e676a7c4b42336f696a683269403550534331343d223246754a4657426c4a677d493a7462585b46637962474d22364e40593b444458623648444742695d22324857465671436b65333959646934335350543d23344/open" border="0" height="1" width="1"><span style="font-family:Helvetica" class="font"><span style="font-size:12px" class="size"><span></span>_______________________________________________</span></span><br></div>
<div><span style="font-family:Helvetica" class="font"><span style="font-size:12px" class="size">swift-evolution mailing list</span></span><br></div>
<div><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</div>
</blockquote></div>
</div>
</div>
<div><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" alt="" src="https://www.fastmailusercontent.com/proxy/8eefdfcb3795df48bd8a6d1794a827cd6bf84b09394d125dd9c9b31e5c4f8765/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e445d22364434385467687d62576251443136346a49494d22324450367248645a5f634438324a475437657a4355507175333b4b644163495449536a5172413649626268734a4549523b6a594137313468326f6958587c64596935786a566952685f4f4b644438543571316a595d2236457a7161705a4c6e445d2236424642496c6239603572665a63635a6f6234685d4f4f6b42657a7858316758376269603234393a5a6552693462686b413a635349757f6a4f65717735314f6743707c43344b694340727a607f4378647a433e63553a7d6760537c473d453d64714542394d23344/open" border="0" height="1" width="1"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div> </div>
</body>
</html>