<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="">Been thinking about the boolean case a bit more, and how to make it better than a ternary using my proposed syntax. So else could be put there to help show it is the opposite. The downside is this makes it mix keywords and operators so seems a bit jarring.&nbsp;<div class=""><br class=""></div><div class=""><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">With the new form parenthesis are built into it and are required:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class="">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">else</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>) </pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">alternatively the bang means do the opposite:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class="">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">!</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// not sure this creates a parsing problem. </span></pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">or if the above causes a parsing problem:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class="">x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> ?(x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">49</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">|</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>)  </pre></div><div class="">Any thoughts?</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 23, 2015, at 7:02 AM, Félix Cloutier 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=""><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="">I know, but that won't support pattern matching.</span><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 class=""><span class="Apple-style-span" style="border-collapse: separate; font-family: 'Lucida Grande'; line-height: normal; border-spacing: 0px;">Félix</span></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 23 déc. 2015 à 02:22:07, David Waite &lt;<a href="mailto:david@alkaline-solutions.com" class="">david@alkaline-solutions.com</a>&gt; a écrit :</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;">In the case where your input is hashable, you could just do:<div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="">&nbsp;i = [.</span><span class="" style="color: rgb(49, 89, 93);">Red</span><span class="">:</span>0xff0000<span class="">, .</span><span class="" style="color: rgb(49, 89, 93);">Green</span><span class="">:</span>0x00ff00<span class="">, .</span><span class="" style="color: rgb(49, 89, 93);">Blue</span><span class="">:</span>0x0000ff<span class="">][</span><span class="" style="color: rgb(79, 129, 135);">color</span><span class="">]</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><span class="" style="font-size: 11px;">this would mean that color must be a Color and not an Optional&lt;Color&gt; (because of swift 2.x limitations)</span></font></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="">-DW</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class=""><br class=""></span></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 22, 2015, at 8:04 AM, Félix Cloutier 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="">I like the gist of it too, though you seem to introduce both a new keyword and a new syntax. (To be clear, I like the syntax but I'm ambivalent towards reusing switch instead of which.)<br class=""><br class="">My minor suggestions would to avoid braces for things that aren't scopes; that either the comma or the the question mark is redundant in their current position (you need a start delimiter or an end delimiter but you don't need both); and that it needs a way to handle a default case if enumeration isn't exhaustive (I'd do that by returning an optional).<br class=""><br class=""><blockquote type="cite" class="">let i = which color (.Red: 0xff0000, .Green: 0x00ff00, .Blue: 0x0000ff) ?? 0x000000<br class=""></blockquote><br class=""><br class="">Thinking out loud, once you remove the question marks it really looks like a dictionary literal, so maybe it could even use square brackets to close the gap.<br class=""><br class=""><blockquote type="cite" class="">let i = which color [.Red: 0xff0000, .Green: 0x00ff00, .Blue: 0x0000ff] ?? 0x000000<br class=""></blockquote><br class=""><br class="">I thought about subscripting a dictionary literal in place:<br class=""><br class=""><blockquote type="cite" class="">[Color.Red: 0xff0000, ...][color] ?? 0x000000<br class=""></blockquote><br class=""><br class="">but that won't support elaborate pattern matching, and I think that this is a deal breaker for the functional folks.<br class=""><br class="">Félix<br class=""><br class=""><blockquote type="cite" class="">Le 22 déc. 2015 à 09:31:32, Charles Constant &lt;<a href="mailto:charles@charlesism.com" class="">charles@charlesism.com</a>&gt; a écrit :<br class=""><br class="">Just goofing on this a little. What if we called it a "which" statement, instead of a "switch" statement? It's a bit cutesy, but not too verbose, and it makes sense if you read it aloud.<br class=""><br class="">let i = which color {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Red: 0xFF0000,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Green: 0x00FF00,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? .Blue: 0x00000FF<br class="">}<br class=""><br class="">let i = which boo {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? true: 1,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? false: 0,<span class="Apple-converted-space">&nbsp;</span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>? nil: -1<br class="">}<br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwyE0wTxxNECMPPCzo-2FHTW73rbbjXg-2BkDsDXavGQRCH-2BQ3MVHuZZpqgJplv86uUZoGsXw4QiMMSHM7Rd5jhg7ISmdEVPAPcJGXs7M4iyRFt8uZ-2FU9A47RmlVFvFti5ZfpkwXHXu-2FstKfyhK3bAm7-2FBt9PJckFHcYKDhCLL-2FdK6cCrvhygEw9ZWe7EDng6hzlirg-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">&nbsp;</span></span><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></body></html>