<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Now *that* reminds me of the _ voodoo in perl... and i was under the impression that magic symbols are not highly regarded in swift (which I really appreciate!!)<br><br>Regards<div>LM</div><div>(From mobile)</div></div><div><br>On May 17, 2016, at 5:31 PM, Patrick Smith via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">Here’s a idea, what if you could use a symbol to denote that you want the same name used?</div><div class=""><br class=""></div><div class="">Here’s an interesting sign from music:&nbsp;<a href="https://en.wikipedia.org/wiki/Repeat_sign" class="">https://en.wikipedia.org/wiki/Repeat_sign</a></div><div class=""><br class=""></div><div class="">Then you can write (one) of these:</div><div class=""><br class=""></div><div class=""><div class="">if let |: = mySomeValue {</div><div class="">&nbsp; // Use unwrapped</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><div class="">if let mySomeValue = :| {</div><div class="">&nbsp; // Use unwrapped</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Not sure which one is more clear. Just a totally random idea! I’m not sure about the above symbols, but it would help in other places too from memory to not have to write the same variable name twice.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 18 May 2016, at 1:18 AM, Matthew Johnson 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 style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On May 17, 2016, at 10:13 AM, Tony Allevato 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 dir="ltr" class=""><div class="">While I've sometimes (early on) wished for a shorter-hand syntax for that construct, I've never been able to think of something that I thought was better. I've gotten to the point where I don't particularly mind it anymore.</div><div class=""><br class=""></div>Regarding the exclamation point specifically, seeing one of those in an expression context says to me "this thing will die horribly if it is nil/throws an error". Using it in this context where that's not the case would probably go against users' expectations.</div></div></blockquote><div class=""><br class=""></div><div class="">Agree. &nbsp;If we are going have syntax similar to pattern matching it should be the same as pattern matching. &nbsp;This would mean using ‘?' rather than ‘!’. &nbsp;However, we already have generalized pattern matching with `if case` for that. &nbsp;This topic has been debated extensively.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, May 17, 2016 at 8:05 AM Vladimir.S via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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;">On 17.05.2016 16:51, Johan Jensen wrote:<br class="">&nbsp;&gt; This was one of the first and most commonly suggested ideas, when the Swift<br class="">&nbsp;&gt; Evolution mailing list first started.<br class="">&nbsp;&gt; Chris Lattner sums it up<br class="">&nbsp;&gt;<br class="">&lt;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html" rel="noreferrer" target="_blank" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html</a>&gt;<br class="">&nbsp;&gt; in one of those threads:<br class="">&nbsp;&gt;<br class="">&nbsp;&gt;&gt; This is commonly requested - the problem is that while it does help<br class="">&nbsp;&gt; reduce boilerplate, it runs counter to the goal of improving clarity.<br class="">&nbsp;&gt;<br class="">&nbsp;&gt; — Johan<br class=""><br class="">Oh, thank you for letting this know.<br class=""><br class="">Well, I totally disagree with Chris. And as soon as there was no 'official'<br class="">proposal and 'official' decision, I'd like to discuss this more.<br class=""><br class="">I saw a lot of code like<br class="">if let mySomeValue = mySomeValue {} in sources and even in books.<br class="">Plus, I really believe that<br class="">if let mySomeValue! {..} is better in any way: readability, less space for<br class="">errors(when you need to repeat the same name) etc<br class=""><br class="">FWIW, I suggest more explicit variant:<br class="">if let value! {...} // with exclamation mark<br class="">In that "old" proposal there was `if let value {...}`, was not so clear.<br class=""><br class="">I can't accept an argument that you can use another name - as usually<br class="">'good' name is already 'crafted' for the instance and you want to use it in<br class="">next code.<br class="">Otherwise, we need a 'best practice' to name optional variables with some<br class="">prefix or suffix like : mySomeValueOpt, then `if let mySomeValue =<br class="">mySomeValueOpt` will have a sense. But as I understand, we don't want to<br class="">use such approach.<br class="">Additionally, when you shadow optional value with same name - you are<br class="">*protecting* yourself from using optional value inside block of unwrapped<br class="">code. IMO it is a good idea.<br class="">And want we or don't want, we already have this practice widely. So I<br class="">believe this(my) proposal will improve the code.<br class=""><br class="">I'd like to get opinion of the community regarding this feature.<br class=""><br class="">On 17.05.2016 16:51, Johan Jensen wrote:<br class="">&gt; This was one of the first and most commonly suggested ideas, when the Swift<br class="">&gt; Evolution mailing list first started.<br class="">&gt; Chris Lattner sums it up<br class="">&gt; &lt;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html" rel="noreferrer" target="_blank" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html</a>&gt;<br class="">&gt; in one of those threads:<br class="">&gt;<br class="">&gt;&gt; This is commonly requested - the problem is that while it does help<br class="">&gt; reduce boilerplate, it runs counter to the goal of improving clarity.<br class="">&gt;<br class="">&gt; — Johan<br class="">&gt;<br class="">&gt; On Tue, May 17, 2016 at 3:43 PM, Vladimir.S via swift-evolution<br class="">&gt; &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><span class="Apple-converted-space">&nbsp;</span>&lt;mailto:<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;&gt; wrote:<br class="">&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;It is common to shadow optional value name with unwrapped value with<br class="">&gt;&nbsp; &nbsp; &nbsp;same name:<br class="">&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;if let someGoodValue = someGoodValue {...}<br class="">&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;What if we'll have a syntax to not repeat the variable name to achieve<br class="">&gt;&nbsp; &nbsp; &nbsp;the same target:<br class="">&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;if let someGoodValue! {...}<br class="">&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;What do you think?<br class="">&gt;&nbsp; &nbsp; &nbsp;_______________________________________________<br class="">&gt;&nbsp; &nbsp; &nbsp;swift-evolution mailing list<br class="">&gt;&nbsp; &nbsp; &nbsp;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><span class="Apple-converted-space">&nbsp;</span>&lt;mailto:<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;<br class="">&gt;&nbsp; &nbsp; &nbsp;<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="">&gt;<br class="">&gt;<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>_______________________________________________<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></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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-caps: 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-caps: 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-caps: 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-caps: 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-caps: 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-caps: 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></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>