<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="">Of course one could just drop it as a grammatical language feature and turn it a standard library feature of some form, e.g.:<div style="font-size: 8px;" class=""><br style="font-size: 8px;" class=""></div><div class=""><font color="#c32275" face="Menlo" class=""><span style="font-size: 14px;" class="">@warn_unused_result<br class=""></span></font><span style="font-family: Menlo; font-size: 14px; color: rgb(195, 34, 117);" class="">func</span><span style="font-family: Menlo; font-size: 14px;" class=""> when<T>(</span><span style="font-family: Menlo; font-size: 14px; color: rgb(195, 34, 117);" class="">@autoclosure</span><span style="font-family: Menlo; font-size: 14px;" class=""> expr: ()-></span><span style="font-family: Menlo; font-size: 14px; color: rgb(112, 61, 170);" class="">Bool</span><span style="font-family: Menlo; font-size: 14px;" class="">, </span><span style="font-family: Menlo; font-size: 14px; color: rgb(195, 34, 117);" class="">@autoclosure</span><span style="font-family: Menlo; font-size: 14px;" class=""> value: ()-></span><span style="font-family: Menlo; font-size: 14px; color: rgb(97, 34, 174);" class="">T</span><span style="font-family: Menlo; font-size: 14px;" class="">, </span><span style="font-family: Menlo; font-size: 14px; color: rgb(195, 34, 117);" class="">@autoclosure</span><span style="font-family: Menlo; font-size: 14px;" class=""> otherwise: ()-></span><span style="font-family: Menlo; font-size: 14px; color: rgb(97, 34, 174);" class="">T</span><span style="font-family: Menlo; font-size: 14px;" class="">) -> </span><span style="font-family: Menlo; font-size: 14px; color: rgb(97, 34, 174);" class="">T</span><span style="font-family: Menlo; font-size: 14px;" class=""> {</span><font color="#c32275" face="Menlo" class=""><span style="font-size: 14px;" class=""><br class=""></span></font><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">if</span> expr() {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">return</span> value()</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">else</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">return</span> otherwise()</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c32275" class="">var</span> a = <span style="font-variant-ligatures: no-common-ligatures; color: #294c50" class="">when</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">1</span> + <span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">1</span> == <span style="font-variant-ligatures: no-common-ligatures; color: #0435ff" class="">2</span>, value: <span style="font-variant-ligatures: no-common-ligatures; color: #c91b13" class="">"works"</span>, otherwise: <span style="font-variant-ligatures: no-common-ligatures; color: #c91b13" class="">"fails"</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4" class="">a</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) </span>// => “works"</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">-DW</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 12:26 AM, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</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 also tend to agree but I don't like the ordering in the Python version and would rather see the introduction of the then keyword<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 04 Dec 2015, at 06:08, Sean Heber <<a href="mailto:sean@fifthace.com" class="">sean@fifthace.com</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 class="">I agree that using ? for ternary feels.. uncomfortable in Swift. I wouldn't mind seeing Python-style or just eliminating it entirely in favor of simplicity.</div><div class=""><br class=""></div><div class="">l8r</div><div class="">Sean<br class=""></div><div class=""><br class="">On Dec 3, 2015, at 10:48 PM, Dan Appel <<a href="mailto:dan.appel00@gmail.com" class="">dan.appel00@gmail.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><span class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; margin: 0px;" class="">I agree that ternary can make code unreadable, especially so with the ‘?’. I personally like the Haskel option the most, but it introduces a new keyword ‘then’, which isn’t great either. Python’s "y if x else z" is therefore, in my opinion, the best alternative.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; margin: 0px;" class="">Also, I found it interesting how split the Rust community was about removing the ternary operator.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; margin: 0px;" class=""><span style="font-family: helvetica, arial;" class="">— </span></div><div id="bloop_sign_1449203852020918016" class="bloop_sign" style="font-family: Helvetica, Arial;"><div style="font-family: helvetica, arial;" class="">Dan Appel</div></div></span></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Dec 3, 2015 at 7:58 PM J. Cheyo Jimenez <<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</a>> wrote:<br class=""></div><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 dir="ltr" class=""><span style="font-size: 12.8px;" class="">Would you consider replacing the C style ?: ternary operator to something that does not use the question mark and colon ? </span><div style="font-size: 12.8px;" class=""><br class=""></div><div style="font-size: 12.8px;" class="">The use of "?" can be confusing when speed reading code with optionals. </div><div style="font-size: 12.8px;" class=""><br class=""></div><div style="font-size: 12.8px;" class="">Consider this code as somebody learning swift as their first language.</div><div style="font-size: 12.8px;" class=""><p class=""><font face="monospace, monospace" class="">let result = !condition ? 1 : 2</font></p></div><div style="font-size: 12.8px;" class=""><br class=""></div><div style="font-size: 12.8px;" class="">Some alternatives:</div><div style="font-size: 12.8px;" class=""><div class=""><br class=""></div><div class="">Haskel <div class=""><div dir="ltr" style="direction: ltr; color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px; line-height: 14.9333px; background-color: rgb(248, 248, 248); background-position: initial initial; background-repeat: initial initial;" class=""><pre style="white-space: pre-wrap; font-family: monospace, Courier; border: 1px solid rgb(221, 221, 221); padding: 1em; line-height: 1.3em; background-color: rgb(249, 249, 249);" class=""><span style="color: rgb(0, 128, 0); font-weight: bold;" class="">if</span> predicate <span style="color: rgb(0, 128, 0); font-weight: bold;" class="">then</span> expr1 <span style="color: rgb(0, 128, 0); font-weight: bold;" class="">else</span> expr2</pre></div><div class="">Python</div></div><div class=""><pre style="white-space: pre-wrap; font-family: monospace, Courier; border: 1px solid rgb(221, 221, 221); padding: 1em; line-height: 1.3em; font-size: 14px; background-color: rgb(249, 249, 249);" class="">result <span style="color: rgb(102, 102, 102);" class="">=</span> x <span style="color: rgb(0, 128, 0); font-weight: bold;" class="">if</span> a <span style="color: rgb(102, 102, 102);" class="">></span> b <span style="color: rgb(0, 128, 0); font-weight: bold;" class="">else</span> y</pre></div><div class="">The advantage of not using the question mark is that the language will be more consistency on the use of "?" to mean only optionals. <br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">References:</div><div class=""><a href="https://devforums.apple.com/message/1020139#1020139" target="_blank" class="">https://devforums.apple.com/message/1020139#1020139</a></div></div></div><div style="font-size: 12.8px;" class=""><a href="https://github.com/rust-lang/rust/issues/1698#issuecomment-3705066" target="_blank" class="">https://github.com/rust-lang/rust/issues/1698#issuecomment-3705066</a></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=4Q3dO0ELn940F2HNV6NWP3n6-2BFmLgXvEeytAtbr-2BgeDYoD5tpBTS72h2nPdoesBjFIHECaHIxYh10FYCXUeWQ65fPIrQZyTNAdleeXCQ64naCq-2BRo4e2zXf0J9A2HRmL88OFXVfBZ5quTXBpurvrqBBs4d-2ByKIvlmbh88TYRH4UfeDBg9-2Fm70jQ1K-2FTBCibgE3e1ZTsN44r9UpWEyJfJ-2F3E-2Fhz7mL2i3piK7DxnoOdI-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CzM39owGTpkJ1zyGXnrRVEXja65D5KHvjV3-2BNib8-2FALErD0kiUUIMIXRwdeL5Lu76KgH2bdx5yKs2bSajEksH7zgA3iXmq0rXx62UiivBwrhmvKJ2lmUUvw-2F1goy53ob9w0N-2B043Vqbsv4aPVvPG12sD1tuiB1iZXAJIXUr6PdM3alK-2Fg1QSW0tRJlIaq-2BL1Q9kmi4L-2BquSs5eiGROE3kA45gCSlnV2ljaEzqH8fWPY-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" 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=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdhDQaJFFM-2BMbJRHzRQnffAg0Zt6UaycrX12nXLIZFiAgcLjU96ZfPh5dRJBCSLNILhlCY95BzqlLpT6pX-2B9q7BavrJVjkYQtQI38LVaaIEPfHKkmPYmu-2BtgwQR1qa66zWTe-2F7Q0MsLc7ADrUiJGrsP6zzDHna2ucVlAZJoSk2u7ptKO4FK165xJajrxeQxQvsc-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=nE9rxSXA5G4kxsTVkgv43vFcOQoCM-2FU-2BigXPSqPoICIFfZbcNsbee6rGb2I1ZvsikSyIfwJLOWBlsISA5AcM-2BEVzz68lmRbXKT1GN3g4-2Fua8mX-2FC0SxWgRW5T13g6zBJYAf2DVYHXjZE2r69csUr2CnmJbQPXZQ-2FOuxaFdiHFbR4BgMF2Lati2Y7h2newc0edCXMwsZeW2wMxPue6ID9SFfggZnqeOK9Yg8C1vdyvnw-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></body></html>