<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=""><div class="">Adding a keyword `unwrap` might reduce the code repetition but I think it will be confusing to use a keyword to unwrap something while we already have a way to do that.</div><div class=""><br class=""></div><div class="">I think two ways to do one thing impacts clarity.</div><div class=""><br class=""></div><div class="">I understand that `unwrap` is a replacement for Optional Binding and optional binding is slightly different from just unwrapping but look at it from the perspective of someone new coming to Swift. Keyword `unwrap` straight away gives a notion of unwrapping an optional instead of the underlying meaning of Optional Binding.</div><div class=""><br class=""></div><div class="">Opinion on `if let value!`</div><div class=""><br class=""></div><div class="">I am not convinced with this style as well and for the same reason of clarity. Here “!” gives a notion that you are just unwrapping “value” instead of optional binding value. Again look at it from the perspective of someone new coming to the Swift.</div><div class=""><br class=""></div><div class="">I think it is equally important to make Swift understandable for newcomers while making it convenient for experienced programmers. Sometimes these newcomers can be entirely new to the concept of programming. So, please keep it in mind while improving the language.</div><div class=""><br class=""></div><div class="">I might be absolutely wrong as I am one of the newcomers who is trying to understand basics from experienced ones here by reading these emails. If that is the case please correct me.</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><br class=""></div><div class="">-Krishna</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 17, 2016, at 9:18 PM, 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:41 AM, Brandon Knope &lt;<a href="mailto:bknope@me.com" class="">bknope@me.com</a>&gt; wrote:</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;">I always thought a new keyword made more sense here:<div class=""><br class=""></div><div class="">if let<span class="Apple-converted-space">&nbsp;</span><font color="#bb2ca2" face="Menlo" class=""><span class="" style="font-size: 12px;">rebind</span></font>&nbsp;someValue {&nbsp;</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>//use shadowed unwrapped value in here</div><div class="">}</div><div class=""><br class=""></div><div class="">if let<span class="Apple-converted-space">&nbsp;</span><font color="#bb2ca2" face="Menlo" class=""><span class="" style="font-size: 12px;">bind</span></font>&nbsp;someValue {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>//use shadowed unwrapped value in here</div><div class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">if let&nbsp;<span class="" style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 12px;">unwrapped&nbsp;</span>someValue {</div><div class=""><br class=""></div><div class="">}</div><div class=""><br class=""></div><div class="">Something along those lines?</div></div></div></blockquote><div class=""><br class=""></div><div class="">I wouldn’t want to see something like this replace the existing `if let` because it doesn’t handle cases where you bind a new name to the result of an expression that returns an optional.</div><div class=""><br class=""></div><div class="">If we did consider something like this it would be simple syntactic sugar for `if let x = x`. &nbsp;Being syntactic sugar for something that is already not too bad means it would need to be as concise as possible. &nbsp;If you want to advocate something like this, maybe consider just `if unwrap`:</div><div class=""><br class=""></div><div class="">if unwrap someValue {</div><div class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">Brandon</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 17, 2016, at 11:31 AM, Patrick Smith 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="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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 class=""><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 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;"><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 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; float: none; display: inline !important;">_______________________________________________</span><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 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; float: none; display: inline !important;">swift-evolution mailing list</span><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;"><a href="mailto:swift-evolution@swift.org" 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;">swift-evolution@swift.org</a><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;"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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;">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></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=""></div></div></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=""><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=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br class=""></div></body></html>