<div dir="ltr"><div>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><br></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><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 17, 2016 at 8:05 AM Vladimir.S via swift-evolution <<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">On 17.05.2016 16:51, Johan Jensen wrote:<br>
> This was one of the first and most commonly suggested ideas, when the Swift<br>
> Evolution mailing list first started.<br>
> Chris Lattner sums it up<br>
><br>
<<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html" rel="noreferrer" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html</a>><br>
> in one of those threads:<br>
><br>
>> This is commonly requested - the problem is that while it does help<br>
> reduce boilerplate, it runs counter to the goal of improving clarity.<br>
><br>
> — Johan<br>
<br>
Oh, thank you for letting this know.<br>
<br>
Well, I totally disagree with Chris. And as soon as there was no 'official'<br>
proposal and 'official' decision, I'd like to discuss this more.<br>
<br>
I saw a lot of code like<br>
if let mySomeValue = mySomeValue {} in sources and even in books.<br>
Plus, I really believe that<br>
if let mySomeValue! {..} is better in any way: readability, less space for<br>
errors(when you need to repeat the same name) etc<br>
<br>
FWIW, I suggest more explicit variant:<br>
if let value! {...} // with exclamation mark<br>
In that "old" proposal there was `if let value {...}`, was not so clear.<br>
<br>
I can't accept an argument that you can use another name - as usually<br>
'good' name is already 'crafted' for the instance and you want to use it in<br>
next code.<br>
Otherwise, we need a 'best practice' to name optional variables with some<br>
prefix or suffix like : mySomeValueOpt, then `if let mySomeValue =<br>
mySomeValueOpt` will have a sense. But as I understand, we don't want to<br>
use such approach.<br>
Additionally, when you shadow optional value with same name - you are<br>
*protecting* yourself from using optional value inside block of unwrapped<br>
code. IMO it is a good idea.<br>
And want we or don't want, we already have this practice widely. So I<br>
believe this(my) proposal will improve the code.<br>
<br>
I'd like to get opinion of the community regarding this feature.<br>
<br>
On 17.05.2016 16:51, Johan Jensen wrote:<br>
> This was one of the first and most commonly suggested ideas, when the Swift<br>
> Evolution mailing list first started.<br>
> Chris Lattner sums it up<br>
> <<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html" rel="noreferrer" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003546.html</a>><br>
> in one of those threads:<br>
><br>
>> This is commonly requested - the problem is that while it does help<br>
> reduce boilerplate, it runs counter to the goal of improving clarity.<br>
><br>
> — Johan<br>
><br>
> On Tue, May 17, 2016 at 3:43 PM, Vladimir.S via swift-evolution<br>
> <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a> <mailto:<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>>> wrote:<br>
><br>
> It is common to shadow optional value name with unwrapped value with<br>
> same name:<br>
><br>
> if let someGoodValue = someGoodValue {...}<br>
><br>
> What if we'll have a syntax to not repeat the variable name to achieve<br>
> the same target:<br>
><br>
> if let someGoodValue! {...}<br>
><br>
> What do you think?<br>
> _______________________________________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a> <mailto:<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>
><br>
><br>
_______________________________________________<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>