<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 17, 2016, at 10:13 AM, Tony Allevato via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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><br class=""></div><div>Agree. If we are going have syntax similar to pattern matching it should be the same as pattern matching. This would mean using ‘?' rather than ‘!’. However, we already have generalized pattern matching with `if case` for that. 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></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 class="">
> This was one of the first and most commonly suggested ideas, when the Swift<br class="">
> Evolution mailing list first started.<br class="">
> Chris Lattner sums it up<br class="">
><br class="">
<<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>><br class="">
> in one of those threads:<br class="">
><br class="">
>> This is commonly requested - the problem is that while it does help<br class="">
> reduce boilerplate, it runs counter to the goal of improving clarity.<br class="">
><br class="">
> — 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="">
> This was one of the first and most commonly suggested ideas, when the Swift<br class="">
> Evolution mailing list first started.<br class="">
> Chris Lattner sums it up<br class="">
> <<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>><br class="">
> in one of those threads:<br class="">
><br class="">
>> This is commonly requested - the problem is that while it does help<br class="">
> reduce boilerplate, it runs counter to the goal of improving clarity.<br class="">
><br class="">
> — Johan<br class="">
><br class="">
> On Tue, May 17, 2016 at 3:43 PM, Vladimir.S via swift-evolution<br class="">
> <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a> <mailto:<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>>> wrote:<br class="">
><br class="">
> It is common to shadow optional value name with unwrapped value with<br class="">
> same name:<br class="">
><br class="">
> if let someGoodValue = someGoodValue {...}<br class="">
><br class="">
> What if we'll have a syntax to not repeat the variable name to achieve<br class="">
> the same target:<br class="">
><br class="">
> if let someGoodValue! {...}<br class="">
><br class="">
> What do you think?<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> <mailto:<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="">
><br class="">
><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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>