<div dir="ltr">Cihat, if either of the two you proposed I would prefer "let foo?" as the bang (!), outside of logical negation, carries a meaning of "this is dangerous and something could go wrong at runtime here". Evidenced by its only other uses--try!, force-unwrapping, and implicitly unwrapped optionals.<div><br></div><div>However, you may be interested in the last email Chris sent in this chain with regards to shortening it to just "let foo":</div><div><br></div><div>"<span style="line-height:1.5">This is commonly requested - the problem is that while it does help reduce boilerplate, it runs counter to the goal of improving clarity.</span><span style="line-height:1.5">"</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">He's got a point; "if let foo = bar" makes sense in a way, but just "if let foo" is a bit nonsensical to me when I take my mind outside of the narrow swift mindset I tend to get into. This extends to decorating the foo with a question mark or a bang, imo. </span></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 19, 2015 at 7:02 PM Cihat Gündüz <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’ve only read the last couple of posts but has anybody already suggested using something like this:</div><div><br></div><div>if let foo! {</div><div> // code that uses foo</div><div>}</div><div><br></div><div>People already know that the ! is unwrapping a value and that let is defining a new constant. So why not combine those two?</div><div>Alternatively it could also be:</div><div><br></div><div>if let foo? {</div><div> // code that uses foo</div><div>}</div><div><br></div><div>What do you think?</div></div><div style="word-wrap:break-word"><div><br></div><div>– Cihat</div></div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>Am 19.12.2015 um 23:43 schrieb Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>>:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br>On Dec 19, 2015, at 2:15 PM, Radosław Pietruszewski via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I was going to suggest something similar (a hard naming problem also):</div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">if has foo {</div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"> // foo is now unwrapped and non-optional</div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">}</div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">guard has foo else { return }</div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">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 style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">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 style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Curious to hear Chris Lattner’s opinion :-) </div></div></blockquote><div><br></div><div>IANACL (I am not a Chris Lattner) but, FWIW, several of us are uncomfortable with the idea that a single declared property might have different static types in different regions of code.</div></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><blockquote type="cite"><div><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>— Radek</div></div><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div>On 19 Dec 2015, at 21:31, Dennis Lysenko via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><p dir="ltr">What if we made the keyword "unwrap"?<span> </span></p><p dir="ltr">if unwrap someViewController {<br>// 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.<span> </span><br>}<span> </span></p><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 19, 2015, 1:31 PM Kevin Wooten via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></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 dir="auto"><div>As much fun as it to example with foo, I would argue the opposite when you use some real world variable names:</div><div><br></div><div>if let someInterestingViewConroller =<span> </span><span style="background-color:rgba(255,255,255,0)">someInterestingViewConroller {</span></div><div><span style="background-color:rgba(255,255,255,0)">}</span></div><div><br></div><div>vs</div><div><br></div><div>If let <span style="background-color:rgba(255,255,255,0)">someInterestingViewConroller {</span></div><div>}</div><div><br></div><div>We know what let does and it should be enough to impart the necessary information for this statement.</div><div><br></div><div>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><br></div></div><div dir="auto"><div><br>On Dec 19, 2015, at 10:01 AM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><br><div><blockquote type="cite"><div>On Dec 11, 2015, at 8:19 AM, Jeff Kelley via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="word-wrap:break-word">I’ve had similar ideas to this. Instead of ditching the<span> </span><font face="Menlo">if let</font><span> </span>syntax altogether, another approach would be to use the existing name if no new name is given, so that this code:<div><br></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>if let foo = foo { /* use foo */ }</font></div><div><br></div><div>could become this code:</div><div><br></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>if let foo { /* use foo */ }</font></div><div><br></div><div>In both cases,<span> </span><font face="Menlo">foo</font><span> </span>is non-optional inside the braces. If you gave it another name with the<span> </span><font face="Menlo">if let</font><span> </span>syntax, that would work as it does today.<br></div></div></div></blockquote><br></div><div>Hi Jeff,</div><div><br></div><div>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><br></div><div>-Chris</div><br><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:0px!important;margin:0px!important;padding:0px!important"></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></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:0px!important;margin:0px!important;padding:0px!important"></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></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="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span> </span>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=JfMPa-2F7wwZPzsZ3QKA8NjtONIYX4SjbWuUxtpfsTY2gGGvses54hx7pDz4V3uNWegt164UwiEZaChRbLGGjSTFIVO5XqTBeOMMs3Q9Lhq7bVMTYxGsdXOQ3Fdm3qOZM5LUSWXBpw088nt-2BY3bOX7hlvysxdFPpKte8Lx5gVWdrR1p2l8xLfcKwEFU8ypPzaKBSKDAEz7gR6bDf-2BOYe6950Wq6EZt5V8DX39Lm2yq4dU-3D" alt="" width="1" height="1" border="0" style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>_______________________________________________</span><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">-Dave<div><br></div><br></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=aT-2FLnFEhPSFDSL7Gmx0xJo5o6hMhPoYO5Zn1SY30wfc5Fce5BmXRas34OQJbk5OtS45Sj6zWco5TZojttWtMDfgI5ezFi7xRbxBNV1UkwQcWl4GC0NJYYKEjNSCRcJntmwM81FV-2F3unsLXI3nhI60ZakU1zEQmO5potDKg1EbhUUn5xBmi98JpQOs3K1ySfs3YOKXYXYzERYjKoWw-2BjdVWvHqZfc-2BNnZcKSBB-2BkoK10-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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPezBQPji3V8PYrw7OOP2Wcr1mIh3u66lt7YLCdmVi9i0IbRkxJiMNtivoX87ncCYncTy7LHfI1QzsYoinATyEHw-2BZpyeNIxI7kmFRhXxlXaBA-2FFOvDURmj0zZaVgNEtRkZtiIhyGwo-2FR9-2F6ZWf465V-2BXQxh3ai7K3T84477v2RoTs2TEz3OhmbPke6k23Lx4aE-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">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>