<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="">I was going to suggest something similar (a hard naming problem also):</div><div class=""><br class=""></div><div class="">if has foo {</div><div class="">&nbsp; &nbsp; // foo is now unwrapped and non-optional</div><div class="">}</div><div class=""><br class=""></div><div class="">guard has foo else { return }</div><div class=""><br class=""></div><div class="">Does the same thing as `let foo = foo` in practice, but places it in a somewhat different mental model. Instead of unwrapping and immediately assigning to a new constant with the same name (which just looks kind of silly, like some magic voodoo ritual), it sort of asserts that we “have” foo (i.e. it’s not nil), and therefore from that point it can just be treated as non-optional.</div><div class=""><br class=""></div><div class="">IMHO this, although introduces a new keyword, makes more sense than trying to reuse “let” in a context where it seems nonsensical. Perhaps this would be closer to Swift’s goals, by reducing very common boilerplate, but without harming clarity in a way adding a new meaning to “let” would.</div><div class=""><br class=""></div><div class="">Curious to hear Chris Lattner’s opinion :-)&nbsp;</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 19 Dec 2015, at 21:31, Dennis Lysenko 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=""><p dir="ltr" class="">What if we made the keyword "unwrap"? </p><p dir="ltr" class="">if unwrap someViewController {<br class="">
 // now there is a shadowing nonoptional (unwrapped) variable of the same name only within this scope, boiling down to simple syntactic sugar for optional binding and it is fairly clear. <br class="">
} </p>
<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sat, Dec 19, 2015, 1:31 PM&nbsp;Kevin Wooten 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class="">As much fun as it to example with foo, I would argue the opposite when you use some real world variable names:</div><div class=""><br class=""></div><div class="">if let someInterestingViewConroller = <span style="background-color:rgba(255,255,255,0)" class="">someInterestingViewConroller {</span></div><div class=""><span style="background-color:rgba(255,255,255,0)" class="">}</span></div><div class=""><br class=""></div><div class="">vs</div><div class=""><br class=""></div><div class="">If let&nbsp;<span style="background-color:rgba(255,255,255,0)" class="">someInterestingViewConroller {</span></div><div class="">}</div><div class=""><br class=""></div><div class="">We know what let does and it should be enough to impart the necessary information for this statement.</div><div class=""><br class=""></div><div class="">When it comes to newcomers I think you'd be hard pressed to find somebody who'd be able to understand either form without teaching; so not losing much there.<br class=""><br class=""></div></div><div dir="auto" class=""><div class=""><br class="">On Dec 19, 2015, at 10:01 AM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 8:19 AM, Jeff Kelley via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">I’ve had similar ideas to this. Instead of ditching the <font face="Menlo" class="">if let</font> syntax altogether, another approach would be to use the existing name if no new name is given, so that this code:<div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="white-space:pre-wrap" class="">        </span>if let foo = foo { /* use foo */ }</font></div><div class=""><br class=""></div><div class="">could become this code:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><span style="white-space:pre-wrap" class="">        </span>if let foo { /* use foo */ }</font></div><div class=""><br class=""></div><div class="">In both cases, <font face="Menlo" class="">foo</font> is non-optional inside the braces. If you gave it another name with the <font face="Menlo" class="">if let</font> syntax, that would work as it does today.<br class=""></div></div></div></blockquote><br class=""></div><div class="">Hi Jeff,</div><div class=""><br class=""></div><div class="">This is commonly requested - the problem is that while it does help reduce boilerplate, it runs counter to the goal of improving clarity.</div><div class=""><br class=""></div><div class="">-Chris</div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1Ry8ov4zuU66O51YNcjYWXuMGf2gObG8uPwoJz-2B4Z1VqMdeyeesw-2Bc9SDkZTEmLmnofSO3tNgiMGF47sxE879Ut5x-2F6sLSrTgmZhXJOq-2B59bEaSmJ0a44hp5limyi-2FpsrcKvySjRuPP0gLr6FoeZNJoisevK-2BimrVdnhvmWcLj69rx67MHqizgTcdJrprVSbV2f-2FkGqilX9aSsmL60yEZg-3D-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!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" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" 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=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPcpzoe4iXPbeaZqrNi2zUlVcdf23NokhHdJZryR37S9aixDNF6tp-2FHf6-2F3lVQio0UE9CBtzVmsMnWQIwW5-2Bf67ND-2F9EF-2BYtV4PpGh922HX58TP5zyNp5Y5ztlmKYymIqTstHghNX4ILNRx0CI2Vk86QzONhMNmZj19pTNa6dGACoMcZLny6tVt4eUiRGI6oOyI-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div>
_______________________________________________<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=4hhvaxvZNsLrnZM9llg93kxoqfFYC8lhv8HAehOIDqJ0WsVCvOCWVPsb4WpAqC68dGVNSd4TE1OXVxisN-2BvOaWvkvMSc478qAQy-2F5AGcS1OxrQKnTsJ-2B4GKd9KyXtAWOq-2FSNo1egb5a1QbUX-2Bdnn9nGEDmx-2F5y8pYGdGhf0y65U40Z9rnr69nF2H14alHW6DXWAEscPtBqiSbqAWpZOc6bO7HoOTulKGMbhP9YaojrY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>