<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="">Addendum, <div class=""><br class=""></div><div class="">ternary for simple things like:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let name = (gender == female) ? “Jill” : “Joe”</div><div class=""><br class=""></div><div class="">Anything more than that then it becomes a hairy mess.</div><div class=""><br class=""></div><div class="">BTW, OOP is good for some solutions, bad for others. But goto is only good in assembly language (IMHO :p). </div><div class=""><br class=""></div><div class="">I would pretty well prefer everything except for assignments (let/var) to be expressions. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 2015-12-20, at 23:57:30, Craig Cruden <<a href="mailto:ccruden@novafore.com" class="">ccruden@novafore.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The complaint that you have about Javascript is more a function of it not being a strongly typed language. If you were to write a function with the type of return specified and the code inside the function (because of a single character) end up changing type for the return value or a future expression that was not expecting boolean…. then it would not compile.<div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On 2015-12-20, at 13:35:42, Charles Constant 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 dir="ltr" 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-size: 13px;" class="">> keeping expressions and statements as separate concepts</span><br class=""><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class="">I </span><span style="font-size: 13px;" class="">seriously </span><span style="font-size: 13px;" class="">could not care less about that.</span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class="">Wait wait, I'm exaggerating! I wouldn't want Swift to become a language like Javascript where you forget to type a single character, and discover your program runs without complaint (assigning some bizarre boolean value as a result).</div><div class=""><br class=""></div><div class="">But if we're talking about the 'Switch' statement, as originally proposed, it takes a lot more characters, and luck, to get your app to compile and run. For me, I'd way rather have the convenience. As far as I'm concerned, unless I'm choosing a variable name, the more I have to type, the more likely I'm going to make a mistake.</div><div class=""><br class=""></div><div class="">This is why I think the ternary, for example, gets a bad rap (a bad rap *at the moment* anyway. I can't keep track, are "goto" and OOP bad this year?). The clarity you gain with a ternary is the fact that "this statement exists to assign a value to Foo." You break that into several lines, and that clarity can evaporate into the ether.</div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class="">So the reason I like your proposal, is that I want a way to preserve that clarity of "this line exists to assign a value to Foo" when I'm mapping something. The existing options, i.e.: the alternatives about I complained earlier in this thread, leave me with extra code whose purpose is solely to support that assignment to Foo. So, let's say I do it by extending an enum with an init that has a corresponding set of values... the purpose of that extension is no longer as clear (e.g.: "this init exists to support a line, somewhere else in this file, that assigns a value to Foo"). If I use a Switch statement, as it currently exists, it's a bunch of lines - and don't forget that "let Foo" needs to be declared *before* the Switch statement because of scope... it's so much more complicated than your proposal.</div><div class=""><br class=""></div><div class="">I don't know if I added anything helpful here other than complaining :) Needless to say, I still support your proposal </div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div></div><div class="gmail_extra" 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="gmail_quote">On Sat, Dec 19, 2015 at 9:57 PM, Paul Ossenbruggen via swift-evolution<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</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=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Dec 19, 2015, at 8:37 PM, Dennis Lysenko via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">+1 to Jordan's points as well. <div class=""><br class=""></div><div class="">Generally speaking, there is clearly a wide variety of things that cause people to be interested in this particular proposal and I don't think we can reconcile all of them. For example, I think that "collapsing an if statement into one line" isn't a good enough reason to introduce the clutter and potential for abuse of the original ternary syntax into a codebase, so I generally float the idea to ban it from projects I'm involved in as soon as I see it pop up in one. At the same time, there seem to be people who are enamored with the concept, and maybe instead they talk in this thread because they want a way to condense a switch statement into one line. And still others think that there is no rush to think about getting rid of ternary, unless we come up with something equally concise or with significant advantages to warrant removing it (all valid points).<br class=""><div class=""><br class=""></div><div class="">I'm not<span class="Apple-converted-space"> </span><i class="">against</i> Paul's idea, but if it matters at all (i.e. if you are worried other people will think like me), if this syntax is released, I will most likely float the idea of opting out of it immediately to my project collaborators. </div><div class=""><br class=""></div><div class="">While interesting for quick, proof of concept coding sessions, it already has some of the readability and abusability disadvantages already present in ternary, and it's still just in the proposal stage. </div><div class=""><br class=""></div><div class="">I only hope that this doesn't preclude progress on turning fully-qualified (and indented) statements into expressions.</div></div></div></div></blockquote><div class=""><br class=""></div></span>Good feedback!<br class=""><div class=""><br class=""></div>Personally, I kind of hope that that is not the direction of Swift. I think there is quite a bit of value in keeping expressions and statements as separate concepts. If you need to do a bunch of things to get the result of an expression then use the statement construct or move it into a method. </div><div class=""><br class=""></div><div class="">Having statements that act as expressions encourages code that has side effects, which goes against one of the core concepts of functional programming. If I am working on a team, and someone wants to add some new feature and they see a big indented “if” with braces, they will just stick it in there and ignore that it is a functional approach. That new statement they add may add a bunch of side effects and add bugs to the code. If it is an expression that temptation will be less likely. They will see that this code is intended to work as an expression and won’t be able to just stick another statement with a bunch of side effects into it. </div><div class=""><br class=""></div><div class="">My proposal is about making expressions into first class citizens in terms of control flow. Its main purpose is definitely not about doing things on one line, that is just a side benefit if it works for your particular situation. This proposal supports and encourages multiline formatting and I think actually makes things cleaner and clearer than the statement forms. </div><div class=""><br class=""></div><div class="">But this feedback and Jordan’s is making me think that the Hybrid approach in Alternatives Considered may be more appealing to everyone. I was thinking conciseness might be preferable given some of the feedback I got from Chris and others, but after reading some other threads, clarity wins out over conciseness. This alternative may win for clarity. So I might go back and rethink that, but before I do that, I hope that more people could tell me if they like it better or do they like the ?( syntax better.</div><div class=""><br class=""></div><div class="">- Paul</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="h5"><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sat, Dec 19, 2015 at 10:57 PM Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</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;"><br class="">> On Dec 19, 2015, at 7:55 PM, Jordan Rose via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class="">><br class="">> It's a nice, consistent proposal, but I don't feel like this solves any of the complaints about the existing ternary operator:<br class="">><br class="">> - It's not obvious what it does when you first learn it.<br class="">> - The '?' doesn't have anything to do with Optionals.<br class="">><br class="">> It is a way to put 'switch' into an expression. I'm not a fan of the two different colons, but that's "just" syntax.<br class=""><br class="">+1 to all that<br class=""><br class="">> Jordan<br class="">><br class="">>> On Dec 18, 2015, at 14:04 , Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class="">>><br class="">>> All,<br class="">>><br class="">>> I think, I finally might have the answer to improving ternary, with such a bold statement come some pretty high expectations but I think, I might actually have done it this time :-)<br class="">>><br class="">>> I am calling it the Demux Expression, it builds on the benefits of ternary and switch while improving on those.<br class="">>><br class="">>><span class="Apple-converted-space"> </span><a href="https://github.com/possen/swift-evolution/blob/master/proposals/0024.md" rel="noreferrer" target="_blank" class="">https://github.com/possen/swift-evolution/blob/master/proposals/0024.md</a><br class="">>><br class="">>> This is a first draft, thanks in advance for feedback!<br class="">>><br class="">>> - Paul<br class="">>> _______________________________________________<br class="">>> swift-evolution mailing list<br class="">>><span class="Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">>><span class="Apple-converted-space"> </span><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="">><br class="">> _______________________________________________<br class="">> swift-evolution mailing list<br class="">><span class="Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">><span class="Apple-converted-space"> </span><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=""><br class="">-Dave<br class=""><br class=""><br class=""><br class="">_______________________________________________<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></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwwzzVRikMe383WAm-2BnOhnC5yVEqJSX7iElquM1RcRrIqPLgfOJ0rpVJ-2Bs29HCyrM-2F1fpH5oasLf5ou4C7YdEV04nIdFH5LRqZWlQRBv2Xj1GKLUwf0iIl8utpViYm706VP4qjWZTNnZBsaVBCU6wlfo8omOWG3vAmjaYnEll9bicpsv8HGYK-2BI-2FW-2FWzXvpdPug-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>_______________________________________________<span class=""><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" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></span></div></blockquote></div><br class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=l3fs1g-2F466j3y5fD5Q61KddsTTCmXL0uxw3XoAMFFNihG7DwRlKVebHq1v-2F2YSp52cMpaAGI8ThDkIwQNIIHnFmUpYpRPdABujgiQaCEORxY8Nm6Y4DCn46rnVlIK36kbWpmPO-2BGM9JoyEOcnVHPM3dYk00evjLu8NwOyKkp1iamHV4vXuKvLfxwRo-2F8nYoPGWUqi-2B2NkHCI-2FMkHR2Ww5WlPhlTJ1n2Ea3WftspmKqg-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=""></div><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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CGU22LnxbYa2EM3wKvzuC6syQDwKa0tMs5IyT5gL1wJ3O3LVXxY0cwBdlVnuKg7PTkmh0AMTftsYx7KHCn50PGKeL4GM-2BsV8xWHb-2FUQnEXTgnylwP7maoDt-2FDGUwmoyxT8m2WAGzJXrhMyVAztYdyjyuUBTNT79isLiKgaTLrCYSxviFsxf26oIvWdAsBb-2BGoV1jxpCVanFlqvyOG1Chr0sn2WHFn90QYGE9iN-2B-2BnVQ-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></div></blockquote></div><br class=""></div></body></html>