<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="">I prefer this style over “if let” &amp; “if var”. &nbsp; I don’t know it is my aversion to “let” because it brings back memories of a language I would prefer to forget (BASIC), but I find the scattering of lets in other statements/expressions to a we bit annoying (especially in pattern matching). &nbsp;<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-29, at 12:54:12, Thorsten Seitz 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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">This is called flow typing in Ceylon and they are using "exists" for that case but testing for conformance with "is" works just the same way there. The latter is of importance because the common use of union types in Ceylon.</div><div class=""><br class=""></div><div class="">if exists foo {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; // foo is non-optional here</div><div class="">}</div><div class=""><br class=""></div><div class="">if foo is String {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; // foo is of type String here</div><div class="">}</div><div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class="">Am 28.01.2016 um 19:08 schrieb Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">&nbsp; &nbsp;if bind foo {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;// foo is non-optional in here</div><div class="">&nbsp; &nbsp;}</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;somethingAsync { [weak self] in</div>&nbsp; &nbsp; &nbsp; &nbsp;guard bind self else { return }<div class="">&nbsp; &nbsp; &nbsp; &nbsp;// ...<br class=""><div class="">&nbsp; &nbsp;}<br class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra">Elegant when you want to rebind the same name!</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Jan 28, 2016 at 10:05 AM, Erica Sadun via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Do you realize how much confusion it would save if Swift just went with<br class="">
<br class="">
if bind foo = bar {...}<br class="">
<br class="">
with let semantics?<br class="">
<br class="">
-- Erica<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
&gt; On Jan 28, 2016, at 11:03 AM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;&gt; On Jan 28, 2016, at 12:43 AM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>&gt; wrote:<br class="">
&gt;&gt;<br class="">
&gt;&gt;&gt; We have a lot of evidence that 'if var' confuses people—a lot of users think that 'if var' and 'var' bindings in case patterns will write back to the original value when this isn't the case.<br class="">
&gt;&gt;<br class="">
&gt;&gt; Can we address this with a diagnostic?<br class="">
&gt;&gt;<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; var bar: Int? = 1<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; if var foo = bar {<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foo += 1&nbsp; &nbsp; &nbsp; &nbsp; // Warning: Value is never used after modification (foo is a copy, not an alias)<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; }<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; print(bar)<br class="">
&gt;<br class="">
&gt; Good idea.<br class="">
&gt;<br class="">
&gt; -Joe<br class="">
&gt; _______________________________________________<br class="">
&gt; swift-evolution mailing list<br class="">
&gt; <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
&gt; <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="">
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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div></div></blockquote></div><br class=""></div></div></div></div>
</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" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></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=""></div></body></html>