<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 10:22 PM, Austin Zheng 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=""><div class="">I am strongly against this proposal.</div><div class=""><br class=""></div><div class="">In terms of clarity: Paul Cantrill made the very good point in a different thread that "beginner-friendly" syntax may not be the same as syntax optimized for the productivity of developers working on serious projects. I think this is a great example of that principle in action. Sigils stand out to the eye when scanning code in a way that keywords don't, even in an IDE with syntax highlighting (and the perils of relying upon relying upon color have been discussed pretty thoroughly in the mandatory 'self' thread). Replacing them with keywords makes it harder to delineate the arguments.<br class=""></div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div>I agree they definitely stand out compared to keywords. also the nil-coelsincg operator when taken with the ternary operator, which seems to me, a spiritual brother, to it may seem even more alien. </div><div><br class=""><blockquote type="cite" class=""><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=""><div class="">In terms of semantics: The argument was made earlier that "?" is associated closely with optionals and not suitable for this purpose; I disagree: "?"'s overarching meaning is that of uncertainty or querying, which makes sense both in terms of control flow (predicate determines which way to go), as well as optionals (whose 'empty or not' status is unknown until explicitly checked for, e.g. via if-let).</div></div></div></blockquote><div><br class=""></div>Again when looking at the nil-coalescing operator, implicit unwrapping (!) and optional chaining, I agree. It seems that the ternary operator fits quite nicely with ? meaning this is a question and that notion is encoded repeated thorough the Swift language. ? is almost a key concept in the language and making it keywords takes away from that and it seems even more wise to keep as is because it was a good design from the start. I also see why Chris and others haven’t really wanted to get into this discussion, but wisely let it happen so we could come to the same conclusion. It is almost as if ? and ! are the core concepts of the language for new Swift learners. </div><div><br class=""><blockquote type="cite" class=""><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=""><div class=""><br class=""></div><div class="">In terms of beginner-friendliness: I don't think the ternary symbols are particularly difficult to learn. The operators show up in other languages as well and the actual usage rules are very simple. On the other hand, I don't think having two related-but-distinct forms of if-else, or mangling multi-line if-else into a form quite dissimilar to those of other languages (or of the other control flow constructs in Swift) is helpful to people learning the language.</div></div></div></blockquote><div><br class=""></div><div>Here I am arguing strongly against my own proposal because I do actually think it might make things worse than better :-) I think there is some value in the process of coming up with the proposal because it spells out what such a feature would/could look like. I suspect that this idea will keep coming up over the years on this list. Is there a way we can setup a FAQ, so that we can show this line of reasoning to newcomers to the list and make sure they are addressing these concerns if they are coming up with new ideas, or do people think that stifles the free flow of new ideas?</div><blockquote type="cite" class=""><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=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">My personal preference is to hold a separate discussion as to whether or not we should have expression variants of the if, switch, and other control flow statements, but even so I don't see them as a replacement for single-line expressions using the ternary operator being discussed.</div></div></div></blockquote><div><br class=""></div>+1</div><div><br class=""><blockquote type="cite" class=""><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=""><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 14, 2015 at 4:50 PM, Nick Shelley 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 dir="ltr" class=""><span 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;"><span style="font-size: 12.8px;" class="">I however frequently hear people saying ternary should be avoided because they are hard to read or they hate them.</span></blockquote><div class=""><br class=""></div></span><div class="">FWIW, I used to be one of those people, but then started working on a team where one member liked them. He didn't force them on us, but after enough code reviews where he showed us how to turn 5-line if/else statements into simple one-line ternary expressions, I got used to reading them and now love them and use them often.</div><div class=""><br class=""></div><div class="">People also hate map, flatMap, reduce, etc., for the same reasons (it's hard for them to read because it's not the for loop they're used to). I think it's a simple matter of getting used to it.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Mon, Dec 14, 2015 at 11:57 AM, Chris Lattner 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=""></div></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 class=""><div class="h5"><div style="word-wrap: break-word;" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 12:19 AM, Paul Ossenbruggen 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 style="word-wrap: break-word;" class="">Once again, thank you for all the feedback, if I sound in anyway grumpy in responding to any email, it has a bit more to do with my cold than the suggestions.<div class=""><br class=""></div><div class="">I have split the original proposal into two proposals and incorporated a bunch of feedback. Splitting it up has been extremely good, not only does it improve readability, I am actually finding I could take or leave the ternary replacement idea. But the proposal will be there if enough everyone thinks it is a good idea. We could put it to a vote to see if there is enough interest and I would be happy to take it further if there is. I suspect this thread would not exist at all if there was no interest in it. However, I am finding I am far more interested in getting switch expressions. <div class=""><div class=""><br class=""></div><div class="">Ternary Replacement</div><div class=""><a href="https://github.com/possen/swift-evolution/blob/master/0021.md" target="_blank" class="">https://github.com/possen/swift-evolution/blob/master/0021.md</a></div></div></div></div></div></blockquote><br class=""></div></span><div class="">Quick comment. The proposal states:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Is it really better? Why not just keep ternary expressions?<br class="">This is a valid question, there is an advantage in compactness to ternary expressions. I however frequently hear people saying ternary should be avoided because they are hard to read or they hate them. There seems to many who either stronly dislike it or don't care.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">However, it doesn’t actually show that it is solving the objections people have to the ternary operator. It is true that some people find the ?: syntax weird, but an equal number of people say that the problem is that you’re putting complex conditional logic inline into the middle of an expression - this proposal actually makes that objection worse. There are also other objections to ?:, and until you enumerate them, it is hard to see whether this proposal is making things better or worse.</div><div class=""><br class=""></div><div class="">-Chris</div></div><br class=""></div></div><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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></span></blockquote></div><br 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></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwwrLncx9By-2BH3ciWVC9Rj4wjhAgi7TU0yq1MksWezqfwX2kMTnrz-2Fulk6zJNH0uPCsSVAJ3NpsGFFoJla0bD8YdtlF3CdGQa0VflqvAJ91k1UYD0sw4mS25ElqzvFLRCaLAwJtGlFTxYFQZE68DiHERhOqAmzLnDkaI4-2BYaaS9XINXBWronhFPMes9-2FKJjXfyo-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=""></body></html>